Permalink
Browse files

Distinguish horz/vert mouse moves in UKIsDragStart, useful for list v…

…iews.
  • Loading branch information...
1 parent 83045d2 commit 3dda63815efe307753d6eb56137dd906787a4003 @uliwitness committed Aug 21, 2010
Showing with 8 additions and 4 deletions.
  1. +2 −1 UKIsDragStart.h
  2. +6 −3 UKIsDragStart.m
View
3 UKIsDragStart.h
@@ -63,7 +63,8 @@ enum
{
UKIsDragStartMouseReleased = 0,
UKIsDragStartTimedOut,
- UKIsDragStartMouseMoved
+ UKIsDragStartMouseMovedHorizontally,
+ UKIsDragStartMouseMovedVertically
};
typedef NSInteger UKIsDragStartResult;
View
9 UKIsDragStart.m
@@ -8,6 +8,8 @@
#import "UKIsDragStart.h"
+#import <iso646.h>
+
UKIsDragStartResult UKIsDragStart( NSEvent *startEvent, NSTimeInterval theTimeout )
{
@@ -45,11 +47,12 @@ UKIsDragStartResult UKIsDragStart( NSEvent *startEvent, NSTimeInterval theTimeou
case NSOtherMouseDragged:
{
NSPoint newPos = [currEvent locationInWindow];
- if( fabs(newPos.x -startPos.x) > 2
- || abs(newPos.y -startPos.y) > 2 )
+ CGFloat xMouseMovement = fabs(newPos.x -startPos.x),
+ yMouseMovement = abs(newPos.y -startPos.y);
+ if( xMouseMovement > 2 or yMouseMovement > 2 )
{
[pool release];
- return UKIsDragStartMouseMoved; // Mouse moved within the wait time, probably a drag!
+ return (xMouseMovement > yMouseMovement) ? UKIsDragStartMouseMovedHorizontally : UKIsDragStartMouseMovedVertically; // Mouse moved within the wait time, probably a drag!
}
break;
}

0 comments on commit 3dda638

Please sign in to comment.