mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Simplify the new drag and drop implementation for NSTextView and fix
some corner cases. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27129 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7e739d6fa3
commit
d1514c3ce1
1 changed files with 12 additions and 19 deletions
|
@ -2580,10 +2580,6 @@ Returns the ranges to which various kinds of user changes should apply.
|
|||
return NSMakeRange(NSNotFound, 0);
|
||||
}
|
||||
|
||||
if (_dragTargetLocation != NSNotFound)
|
||||
{
|
||||
return NSMakeRange(_dragTargetLocation, 0);
|
||||
}
|
||||
return _layoutManager->_selected_range;
|
||||
}
|
||||
|
||||
|
@ -4555,6 +4551,8 @@ other than copy/paste or dragging. */
|
|||
flags = NSDragOperationNone;
|
||||
}
|
||||
}
|
||||
else if (_dragTargetLocation != NSNotFound)
|
||||
[self _draggingReleaseInsertionPoint];
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
@ -4586,17 +4584,14 @@ other than copy/paste or dragging. */
|
|||
flags = NSDragOperationNone;
|
||||
}
|
||||
}
|
||||
else if (_dragTargetLocation != NSNotFound)
|
||||
[self _draggingReleaseInsertionPoint];
|
||||
return flags;
|
||||
}
|
||||
|
||||
- (void) draggingExited: (id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard *pboard = [sender draggingPasteboard];
|
||||
NSArray *types = [self readablePasteboardTypes];
|
||||
NSString *type = [self preferredPasteboardTypeFromArray: [pboard types]
|
||||
restrictedToTypesFromArray: types];
|
||||
if (_dragTargetLocation != NSNotFound
|
||||
&& ![type isEqual:NSColorPboardType])
|
||||
if (_dragTargetLocation != NSNotFound)
|
||||
{
|
||||
[self _draggingReleaseInsertionPoint];
|
||||
}
|
||||
|
@ -4609,27 +4604,25 @@ other than copy/paste or dragging. */
|
|||
|
||||
- (BOOL) performDragOperation: (id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSRange sourceRange = [self selectedRange];
|
||||
NSRange changeRange = NSMakeRange(_dragTargetLocation, 0);
|
||||
[self _draggingReleaseInsertionPoint];
|
||||
[self setSelectedRange: changeRange];
|
||||
|
||||
if ([sender draggingSource] == self &&
|
||||
([sender draggingSourceOperationMask] & NSDragOperationGeneric))
|
||||
{
|
||||
NSRange changeRange = [self selectedRange];
|
||||
if (![self shouldChangeTextInRange: changeRange replacementString: @""])
|
||||
if (![self shouldChangeTextInRange: sourceRange replacementString: @""])
|
||||
{
|
||||
[self _draggingReleaseInsertionPoint];
|
||||
return NO;
|
||||
}
|
||||
if (_dragTargetLocation >= NSMaxRange(changeRange))
|
||||
_dragTargetLocation -= changeRange.length;
|
||||
else if (_dragTargetLocation >= changeRange.location)
|
||||
_dragTargetLocation = changeRange.location;
|
||||
[self replaceCharactersInRange: changeRange withString: @""];
|
||||
[self replaceCharactersInRange: sourceRange withString: @""];
|
||||
}
|
||||
return [self readSelectionFromPasteboard: [sender draggingPasteboard]];
|
||||
}
|
||||
|
||||
- (void) concludeDragOperation: (id <NSDraggingInfo>)sender
|
||||
{
|
||||
[self _draggingReleaseInsertionPoint];
|
||||
}
|
||||
|
||||
- (void) cleanUpAfterDragOperation
|
||||
|
|
Loading…
Reference in a new issue