From fec2a18dd328b2fb5fe92bf3b240a838050ebdf6 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Fri, 23 Apr 2010 02:13:54 +0000 Subject: [PATCH] #3006 Allow Trackers to be copied in Create Window --- macosx/CreatorWindowController.h | 1 + macosx/CreatorWindowController.m | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/macosx/CreatorWindowController.h b/macosx/CreatorWindowController.h index 811a3ca25..62dc8e62b 100644 --- a/macosx/CreatorWindowController.h +++ b/macosx/CreatorWindowController.h @@ -60,6 +60,7 @@ - (void) addRemoveTracker: (id) sender; +- (void) copy: (id) sender; - (void) paste: (id) sender; @end diff --git a/macosx/CreatorWindowController.m b/macosx/CreatorWindowController.m index 3610e41f1..c83095197 100644 --- a/macosx/CreatorWindowController.m +++ b/macosx/CreatorWindowController.m @@ -322,10 +322,31 @@ [fTrackerAddRemoveControl setEnabled: [fTrackerTable numberOfSelectedRows] > 0 forSegment: TRACKER_REMOVE_TAG]; } +- (void) copy: (id) sender +{ + NSArray * addresses = [fTrackers objectsAtIndexes: [fTrackerTable selectedRowIndexes]]; + NSString * text = [addresses componentsJoinedByString: @"\n"]; + + NSPasteboard * pb = [NSPasteboard generalPasteboard]; + if ([NSApp isOnSnowLeopardOrBetter]) + { + [pb clearContents]; + [pb writeObjects: [NSArray arrayWithObject: text]]; + } + else + { + [pb declareTypes: [NSArray arrayWithObject: NSStringPboardType] owner: nil]; + [pb setString: text forType: NSStringPboardType]; + } +} + - (BOOL) validateMenuItem: (NSMenuItem *) menuItem { const SEL action = [menuItem action]; + if (action == @selector(copy:)) + return [[self window] firstResponder] == fTrackerTable && [fTrackerTable numberOfSelectedRows] > 0; + if (action == @selector(paste:)) return [[self window] firstResponder] == fTrackerTable && ([NSApp isOnSnowLeopardOrBetter]