implement draggingExited: to autoscroll during the IBAction connection if needed

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@26544 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fabien Vallon 2008-05-20 17:49:54 +00:00
parent b908ca07b1
commit b68527e3ec

View file

@ -30,6 +30,8 @@
#include "GormFunctions.h"
#include "GormDocument.h"
#include "GormClassManager.h"
#include <AppKit/NSClipView.h>
/*
* Method to return the image that should be used to display objects within
* the matrix containing the objects in a document.
@ -277,6 +279,43 @@ static NSMapTable *docMap = 0;
return NSDragOperationNone;
}
/**
* Used for autoscrolling when you connect IBActions.
* FIXME: Maybye there is a better way to do it.
*/
- (void)draggingExited:(id < NSDraggingInfo >)sender
{
if (dragType == GormLinkPboardType)
{
NSRect documentVisibleRect;
NSRect documentRect;
NSPoint loc = [sender draggingLocation];
loc = [self convertPoint:loc fromView:nil];
documentVisibleRect = [(NSClipView *)[self superview] documentVisibleRect];
documentRect = [(NSClipView *)[self superview] documentRect];
/* Down */
if ( (loc.y >= documentVisibleRect.size.height)
&& ( ! NSEqualRects(documentVisibleRect,documentRect) ) )
{
loc.x = 0;
loc.y = documentRect.origin.y + [self cellSize].height;
[(NSClipView*) [self superview] scrollToPoint:loc];
}
/* up */
else if ( (loc.y + 10 >= documentVisibleRect.origin.y )
&& ( ! NSEqualRects(documentVisibleRect,documentRect) ) )
{
loc.x = 0;
loc.y = documentRect.origin.y - [self cellSize].height;
[(NSClipView*) [self superview] scrollToPoint:loc];
}
}
}
- (unsigned int) draggingSourceOperationMaskForLocal: (BOOL)flag
{
return NSDragOperationLink;