Select pasted text in a text view after a DnD operation.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@30053 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Wolfgang Lux 2010-03-27 21:17:00 +00:00
parent 04e0376187
commit 79ef3c7045
2 changed files with 25 additions and 4 deletions

View file

@ -1,5 +1,8 @@
2010-03-27 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSTextView.m (-performDragOperation:): Select pasted text
after a DnD operation.
* Source/NSWindowController.m (-synchronizeWindowTitleWithDocumentName):
Show a document's represented file name also when its display name
is equal to the last path component of the file name, since that

View file

@ -4933,8 +4933,7 @@ other than copy/paste or dragging. */
restrictedToTypesFromArray: types];
unsigned int flags = [self dragOperationForDraggingInfo: sender type: type];
if (flags != NSDragOperationNone
&& ![type isEqual:NSColorPboardType])
if (flags != NSDragOperationNone && ![type isEqual: NSColorPboardType])
{
NSPoint dragPoint;
unsigned dragIndex;
@ -5016,9 +5015,13 @@ other than copy/paste or dragging. */
selection and hence _dragTargetLocation==NSNotFound in that case. */
NSSelectionGranularity gran = [self selectionGranularity];
NSRange sourceRange = [self selectedRange];
NSRange changeRange;
NSPasteboard *pboard;
NSString *type;
if (_dragTargetLocation != NSNotFound)
{
NSRange changeRange = NSMakeRange(_dragTargetLocation, 0);
changeRange = NSMakeRange(_dragTargetLocation, 0);
[self _draggingReleaseInsertionPoint];
[self setSelectedRange: changeRange];
}
@ -5034,7 +5037,22 @@ other than copy/paste or dragging. */
}
[self replaceCharactersInRange: sourceRange withString: @""];
}
return [self readSelectionFromPasteboard: [sender draggingPasteboard]];
changeRange = [self rangeForUserTextChange];
pboard = [sender draggingPasteboard];
type = [self preferredPasteboardTypeFromArray: [pboard types]
restrictedToTypesFromArray: [self readablePasteboardTypes]];
if ([self readSelectionFromPasteboard: pboard type: type])
{
if (![type isEqual: NSColorPboardType])
{
changeRange.length =
[self selectedRange].location - changeRange.location;
[self setSelectedRange: changeRange];
}
return YES;
}
return NO;
}
- (void) concludeDragOperation: (id <NSDraggingInfo>)sender