mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 09:31:19 +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
8836143273
commit
711a1b824e
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);
|
return NSMakeRange(NSNotFound, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_dragTargetLocation != NSNotFound)
|
|
||||||
{
|
|
||||||
return NSMakeRange(_dragTargetLocation, 0);
|
|
||||||
}
|
|
||||||
return _layoutManager->_selected_range;
|
return _layoutManager->_selected_range;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4555,6 +4551,8 @@ other than copy/paste or dragging. */
|
||||||
flags = NSDragOperationNone;
|
flags = NSDragOperationNone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (_dragTargetLocation != NSNotFound)
|
||||||
|
[self _draggingReleaseInsertionPoint];
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4586,17 +4584,14 @@ other than copy/paste or dragging. */
|
||||||
flags = NSDragOperationNone;
|
flags = NSDragOperationNone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (_dragTargetLocation != NSNotFound)
|
||||||
|
[self _draggingReleaseInsertionPoint];
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) draggingExited: (id <NSDraggingInfo>)sender
|
- (void) draggingExited: (id <NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
NSPasteboard *pboard = [sender draggingPasteboard];
|
if (_dragTargetLocation != NSNotFound)
|
||||||
NSArray *types = [self readablePasteboardTypes];
|
|
||||||
NSString *type = [self preferredPasteboardTypeFromArray: [pboard types]
|
|
||||||
restrictedToTypesFromArray: types];
|
|
||||||
if (_dragTargetLocation != NSNotFound
|
|
||||||
&& ![type isEqual:NSColorPboardType])
|
|
||||||
{
|
{
|
||||||
[self _draggingReleaseInsertionPoint];
|
[self _draggingReleaseInsertionPoint];
|
||||||
}
|
}
|
||||||
|
@ -4609,27 +4604,25 @@ other than copy/paste or dragging. */
|
||||||
|
|
||||||
- (BOOL) performDragOperation: (id <NSDraggingInfo>)sender
|
- (BOOL) performDragOperation: (id <NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
|
NSRange sourceRange = [self selectedRange];
|
||||||
|
NSRange changeRange = NSMakeRange(_dragTargetLocation, 0);
|
||||||
|
[self _draggingReleaseInsertionPoint];
|
||||||
|
[self setSelectedRange: changeRange];
|
||||||
|
|
||||||
if ([sender draggingSource] == self &&
|
if ([sender draggingSource] == self &&
|
||||||
([sender draggingSourceOperationMask] & NSDragOperationGeneric))
|
([sender draggingSourceOperationMask] & NSDragOperationGeneric))
|
||||||
{
|
{
|
||||||
NSRange changeRange = [self selectedRange];
|
if (![self shouldChangeTextInRange: sourceRange replacementString: @""])
|
||||||
if (![self shouldChangeTextInRange: changeRange replacementString: @""])
|
|
||||||
{
|
{
|
||||||
[self _draggingReleaseInsertionPoint];
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
if (_dragTargetLocation >= NSMaxRange(changeRange))
|
[self replaceCharactersInRange: sourceRange withString: @""];
|
||||||
_dragTargetLocation -= changeRange.length;
|
|
||||||
else if (_dragTargetLocation >= changeRange.location)
|
|
||||||
_dragTargetLocation = changeRange.location;
|
|
||||||
[self replaceCharactersInRange: changeRange withString: @""];
|
|
||||||
}
|
}
|
||||||
return [self readSelectionFromPasteboard: [sender draggingPasteboard]];
|
return [self readSelectionFromPasteboard: [sender draggingPasteboard]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) concludeDragOperation: (id <NSDraggingInfo>)sender
|
- (void) concludeDragOperation: (id <NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
[self _draggingReleaseInsertionPoint];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) cleanUpAfterDragOperation
|
- (void) cleanUpAfterDragOperation
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue