Added method [copySelection] and [pasteSelection] to put the

selected text in special pasteboard. The first gets called by
[setSelectedRange:affinity:stillSelecting:] while the later is
bound to [middleMouseUp:]. (This is hard coded, could the key
binding code handle this?)


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@12815 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2002-02-27 09:41:20 +00:00
parent f3e6d43e5b
commit 742a2bc434

View file

@ -139,6 +139,8 @@ static NSNotificationCenter *nc;
//
- (void) setAttributes: (NSDictionary *) attributes range: (NSRange) aRange;
- (void) _illegalMovement: (int) notNumber;
- (void) copySelection;
- (void) pasteSelection;
@end
@implementation NSTextView
@ -1373,6 +1375,9 @@ static NSNotificationCenter *nc;
/* Insertion Point */
if (range.length)
{
// Store the selected text in the selection pasteboard
[self copySelection];
if (_insertionPointTimer != nil)
{
[_insertionPointTimer invalidate];
@ -4033,6 +4038,29 @@ other than copy/paste or dragging. */
return [_layoutManager boundingRectForGlyphRange: glyphRange
inTextContainer: _textContainer];
}
/** Extension method that copies the current selected text to the
special section pasteboard */
- (void) copySelection
{
[self writeSelectionToPasteboard: [NSPasteboard pasteboardWithName: @"Selection"]
type: NSStringPboardType];
}
/** Extension method that pastes the current selected text from the
special section pasteboard */
- (void) pasteSelection
{
[self readSelectionFromPasteboard: [NSPasteboard pasteboardWithName: @"Selection"]
type: NSStringPboardType];
}
/** Bind middle mouse up to pasteSelection. This should be done via configuation! */
- (void) middleMouseUp: (NSEvent*)theEvent
{
// Should we change the insertion point, based on the event position?
[self pasteSelection];
}
@end