projects
/
enjoyable.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
abe3d19
)
Also store the mouse location and don't double-click if it moved.
author
Joe Wreschnig
<joe.wreschnig@gmail.com>
Sat, 9 Mar 2013 12:41:27 +0000
(13:41 +0100)
committer
Joe Wreschnig
<joe.wreschnig@gmail.com>
Sat, 9 Mar 2013 12:41:27 +0000
(13:41 +0100)
Classes/NJOutputMouseButton.m
patch
|
blob
|
history
diff --git
a/Classes/NJOutputMouseButton.m
b/Classes/NJOutputMouseButton.m
index
18d82ff
..
bc286bd
100644
(file)
--- a/
Classes/NJOutputMouseButton.m
+++ b/
Classes/NJOutputMouseButton.m
@@
-10,6
+10,7
@@
@implementation NJOutputMouseButton {
NSDate *upTime;
int clickCount;
@implementation NJOutputMouseButton {
NSDate *upTime;
int clickCount;
+ NSPoint clickPosition;
}
+ (NSTimeInterval)doubleClickInterval {
}
+ (NSTimeInterval)doubleClickInterval {
@@
-51,8
+52,8
@@
CGPointMake(mouseLoc.x, height - mouseLoc.y),
_button);
CGPointMake(mouseLoc.x, height - mouseLoc.y),
_button);
- NSLog(@"%@\n%@", upTime, [NSDate date]);
-
if (clickCount >= 3 || [upTime compare:[NSDate date]] == NSOrderedAscending
)
+ if (clickCount >= 3 || [upTime compare:[NSDate date]] == NSOrderedAscending
+
|| !CGPointEqualToPoint(NSEvent.mouseLocation, clickPosition)
)
clickCount = 1;
else
++clickCount;
clickCount = 1;
else
++clickCount;
@@
-63,17
+64,17
@@
}
- (void)untrigger {
}
- (void)untrigger {
+ upTime = [NJOutputMouseButton dateWithClickInterval];
+ clickPosition = NSEvent.mouseLocation;
CGFloat height = NSScreen.mainScreen.frame.size.height;
CGFloat height = NSScreen.mainScreen.frame.size.height;
- NSPoint mouseLoc = NSEvent.mouseLocation;
CGEventType eventType = (_button == kCGMouseButtonLeft) ? kCGEventLeftMouseUp : kCGEventRightMouseUp;
CGEventRef click = CGEventCreateMouseEvent(NULL,
eventType,
CGEventType eventType = (_button == kCGMouseButtonLeft) ? kCGEventLeftMouseUp : kCGEventRightMouseUp;
CGEventRef click = CGEventCreateMouseEvent(NULL,
eventType,
- CGPointMake(
mouseLoc.x, height - mouseLoc
.y),
+ CGPointMake(
clickPosition.x, height - clickPosition
.y),
_button);
CGEventSetIntegerValueField(click, kCGMouseEventClickState, clickCount);
CGEventPost(kCGHIDEventTap, click);
CFRelease(click);
_button);
CGEventSetIntegerValueField(click, kCGMouseEventClickState, clickCount);
CGEventPost(kCGHIDEventTap, click);
CFRelease(click);
- upTime = [NJOutputMouseButton dateWithClickInterval];
}
@end
}
@end