diff --git a/ChangeLog b/ChangeLog index e13b561cc..b41a1d04e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-09-08 Fred Kiefer + + * Source/GSInfoPanel.m (-keyDown:, -copy:): Added functionality to + copy the text content of the info panel to the pasteboard. + Fixes #23831. + 2008-09-08 Fred Kiefer * Source/NSSavePanel.m (-browser:createRowsForColumn:inMatrix:): diff --git a/Source/GSInfoPanel.m b/Source/GSInfoPanel.m index 8bd6a3b7d..0bb0ab4a0 100644 --- a/Source/GSInfoPanel.m +++ b/Source/GSInfoPanel.m @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -37,6 +38,7 @@ #include "AppKit/NSFont.h" #include "AppKit/NSImage.h" #include "AppKit/NSImageView.h" +#include "AppKit/NSPasteboard.h" #include "AppKit/NSTextField.h" #include "GNUstepGUI/GSInfoPanel.h" #include "GNUstepGUI/GSTheme.h" @@ -656,4 +658,50 @@ new_label (NSString *value) return self; } +- (void) copy: (id)sender +{ + NSArray *types = [NSArray arrayWithObject: NSStringPboardType]; + NSPasteboard *pboard = [NSPasteboard generalPasteboard]; + NSMutableString *text = [[NSMutableString alloc] init]; + NSView *cv = [self contentView]; + NSEnumerator *enumerator = [[cv subviews] objectEnumerator]; + NSView *subview; + + // Loop over all the text subviews and collect the information + while ((subview = [enumerator nextObject]) != nil) + { + if ([subview isKindOfClass: [NSTextField class]]) + { + [text appendString: [(NSTextField*)subview stringValue]]; + [text appendString: @"\n"]; + } + } + + [pboard declareTypes: types owner: self]; + [pboard setString: text + forType: NSStringPboardType]; + RELEASE(text); +} + +- (void) keyDown: (NSEvent*)theEvent +{ + NSString *characters = [theEvent characters]; + unichar character = 0; + + if ([characters length] > 0) + { + character = [characters characterAtIndex: 0]; + } + + // FIXME: Hard coded + if (character == 'c' && + [theEvent modifierFlags] & NSCommandKeyMask) + { + [self copy: nil]; + return; + } + + [super keyDown: theEvent]; +} + @end