Changeset 3040


Ignore:
Timestamp:
Sep 11, 2007, 12:44:15 AM (14 years ago)
Author:
livings124
Message:

add ability to copy to the message window, and allow multiple selection

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/MessageWindowController.m

    r3038 r3040  
    165165{
    166166    [fMessages sortUsingDescriptors: [fMessageTable sortDescriptors]];
    167    
    168167    [fMessageTable reloadData];
     168}
     169
     170- (void) copy: (id) sender
     171{
     172    NSIndexSet * indexes = [fMessageTable selectedRowIndexes];
     173    NSMutableArray * messageStrings = [NSMutableArray arrayWithCapacity: [indexes count]];
     174   
     175    unsigned int i;
     176    for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
     177        [messageStrings addObject: [self stringForMessage: [fMessages objectAtIndex: i]]];
     178   
     179    NSPasteboard * pb = [NSPasteboard generalPasteboard];
     180    [pb declareTypes: [NSArray arrayWithObject: NSStringPboardType] owner: self];
     181    [pb setString: [messageStrings componentsJoinedByString: @"\n"] forType: NSStringPboardType];
     182}
     183
     184- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
     185{
     186    SEL action = [menuItem action];
     187   
     188    if (action == @selector(copy:))
     189        return [fMessageTable numberOfSelectedRows] > 0;
     190   
     191    return YES;
    169192}
    170193
Note: See TracChangeset for help on using the changeset viewer.