projects
/
enjoyable.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Split NJMappingController view handling off into NJMappingViewController. This is...
[enjoyable.git]
/
Classes
/
NJOutputMouseButton.m
diff --git
a/Classes/NJOutputMouseButton.m
b/Classes/NJOutputMouseButton.m
index
18d82ff
..
e01e763
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 {
@@
-36,7
+37,7
@@
}
+ (NJOutput *)outputDeserialize:(NSDictionary *)serialization
}
+ (NJOutput *)outputDeserialize:(NSDictionary *)serialization
- withMappings:(
NSArray *
)mappings {
+ withMappings:(
id <NSFastEnumeration>
)mappings {
NJOutputMouseButton *output = [[NJOutputMouseButton alloc] init];
output.button = [serialization[@"button"] intValue];
return output;
NJOutputMouseButton *output = [[NJOutputMouseButton alloc] init];
output.button = [serialization[@"button"] intValue];
return output;
@@
-45,27
+46,32
@@
- (void)trigger {
CGFloat height = NSScreen.mainScreen.frame.size.height;
NSPoint mouseLoc = NSEvent.mouseLocation;
- (void)trigger {
CGFloat height = NSScreen.mainScreen.frame.size.height;
NSPoint mouseLoc = NSEvent.mouseLocation;
- CGEventType eventType = (_button == kCGMouseButtonLeft) ? kCGEventLeftMouseDown : kCGEventRightMouseDown;
+ CGEventType eventType = _button == kCGMouseButtonLeft ? kCGEventLeftMouseDown
+ : _button == kCGMouseButtonRight ? kCGEventRightMouseDown
+ : kCGEventOtherMouseDown;
CGEventRef click = CGEventCreateMouseEvent(NULL,
eventType,
CGPointMake(mouseLoc.x, height - mouseLoc.y),
_button);
CGEventRef click = CGEventCreateMouseEvent(NULL,
eventType,
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(mouseLoc, clickPosition)
)
clickCount = 1;
else
++clickCount;
CGEventSetIntegerValueField(click, kCGMouseEventClickState, clickCount);
clickCount = 1;
else
++clickCount;
CGEventSetIntegerValueField(click, kCGMouseEventClickState, clickCount);
-
CGEventPost(kCGHIDEventTap, click);
CFRelease(click);
CGEventPost(kCGHIDEventTap, click);
CFRelease(click);
+ clickPosition = mouseLoc;
}
- (void)untrigger {
}
- (void)untrigger {
-
CGFloat height = NSScreen.mainScreen.frame.size.height
;
+
upTime = [NJOutputMouseButton dateWithClickInterval]
;
NSPoint mouseLoc = NSEvent.mouseLocation;
NSPoint mouseLoc = NSEvent.mouseLocation;
- CGEventType eventType = (_button == kCGMouseButtonLeft) ? kCGEventLeftMouseUp : kCGEventRightMouseUp;
+ CGFloat height = NSScreen.mainScreen.frame.size.height;
+ CGEventType eventType = _button == kCGMouseButtonLeft ? kCGEventLeftMouseUp
+ : _button == kCGMouseButtonRight ? kCGEventRightMouseUp
+ : kCGEventOtherMouseUp;
CGEventRef click = CGEventCreateMouseEvent(NULL,
eventType,
CGPointMake(mouseLoc.x, height - mouseLoc.y),
CGEventRef click = CGEventCreateMouseEvent(NULL,
eventType,
CGPointMake(mouseLoc.x, height - mouseLoc.y),
@@
-73,7
+79,6
@@
CGEventSetIntegerValueField(click, kCGMouseEventClickState, clickCount);
CGEventPost(kCGHIDEventTap, click);
CFRelease(click);
CGEventSetIntegerValueField(click, kCGMouseEventClickState, clickCount);
CGEventPost(kCGHIDEventTap, click);
CFRelease(click);
- upTime = [NJOutputMouseButton dateWithClickInterval];
}
@end
}
@end