Scroll NSTextView during dragging if the mouse pointer is close to the

border of the view's visible rectangle.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27313 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Wolfgang Lux 2008-12-16 21:13:21 +00:00
parent 50a4201f22
commit 37cb9d46b0
3 changed files with 65 additions and 0 deletions

View file

@ -1,3 +1,12 @@
2008-12-16 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSTextView.m (-draggingUpated:): Scroll during dragging
if the mouse pointer is close to the border of the view's visible
rectangle.
* Source/GSDragView.m (-handleEventDuringDragging:): Periodically
send -draggingUpdated: messages to the dragging destination.
2008-12-16 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSWorkspace.m: Fix problem failing to recognise path extension

View file

@ -834,6 +834,22 @@ static GSDragView *sharedDragView = nil;
{
[self _updateAndMoveImageToCorrectPosition];
}
else if (destWindow)
{
[self _sendLocalEvent: GSAppKitDraggingUpdate
action: dragMask & operationMask
position: newPosition
timestamp: [theEvent timestamp]
toWindow: destWindow];
}
else
{
[self sendExternalEvent: GSAppKitDraggingUpdate
action: dragMask & operationMask
position: newPosition
timestamp: [theEvent timestamp]
toWindow: targetWindowRef];
}
break;
default:
NSLog(@"Internal: dropped event (%d) during dragging", [theEvent type]);

View file

@ -4585,12 +4585,52 @@ other than copy/paste or dragging. */
{
NSPoint dragPoint;
unsigned dragIndex;
NSRect vRect;
dragPoint = [sender draggingLocation];
dragPoint = [self convertPoint: dragPoint fromView: nil];
dragIndex = [self _characterIndexForPoint: dragPoint
respectFraction: YES];
/* Note: Keep DRAGGING_SCROLL_BORDER in sync with a similar value used
* in -draggingUpdated: of NSOutlineView and NSTableView.
* FIXME: Is the value of DRAGGING_SCROLL_DIST reasonable?
*/
#define DRAGGING_SCROLL_BORDER 3
#define DRAGGING_SCROLL_DIST 10
vRect = [self visibleRect];
if (dragPoint.x <= NSMinX(vRect) + DRAGGING_SCROLL_BORDER)
{
vRect.origin.x -= DRAGGING_SCROLL_DIST;
if (NSMinX(vRect) < NSMinX(_bounds))
vRect.origin.x = NSMinX(_bounds);
[self scrollPoint: vRect.origin];
}
else if (dragPoint.x >= NSMaxX(vRect) - DRAGGING_SCROLL_BORDER)
{
vRect.origin.x += DRAGGING_SCROLL_DIST;
if (NSMaxX(vRect) > NSMaxX(_bounds))
vRect.origin.x = NSMaxX(_bounds) - NSWidth(vRect);
[self scrollPoint: vRect.origin];
}
if (dragPoint.y <= NSMinY(vRect) + DRAGGING_SCROLL_BORDER)
{
vRect.origin.y -= DRAGGING_SCROLL_DIST;
if (NSMinY(vRect) < NSMinY(_bounds))
vRect.origin.y = NSMinY(_bounds);
[self scrollPoint: vRect.origin];
}
else if (dragPoint.y >= NSMaxY(vRect) - DRAGGING_SCROLL_BORDER)
{
vRect.origin.y += DRAGGING_SCROLL_DIST;
if (NSMaxY(vRect) > NSMaxY(_bounds))
vRect.origin.y = NSMaxY(_bounds) - NSHeight(vRect);
[self scrollPoint: vRect.origin];
}
#undef DRAGGING_SCROLL_BORDER
#undef DRAGGING_SCROLL_DIST
if ([sender draggingSource] != self ||
!NSLocationInRange(dragIndex, [self selectedRange]))
[self _draggingHijackInsertionPoint: dragIndex];