Added functionality to copy the text content of the info panel

to the pasteboard.
Fixes #23831.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26838 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2008-09-09 15:58:08 +00:00
parent 31293f108c
commit 829457697a
2 changed files with 54 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2008-09-08 Fred Kiefer <FredKiefer@gmx.de>
* 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 <FredKiefer@gmx.de>
* Source/NSSavePanel.m (-browser:createRowsForColumn:inMatrix:):

View file

@ -28,6 +28,7 @@
#include <Foundation/NSBundle.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSEnumerator.h>
#include <Foundation/NSString.h>
#include <Foundation/NSProcessInfo.h>
@ -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