X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=TargetMouseBtn.m;fp=TargetMouseBtn.m;h=0000000000000000000000000000000000000000;hp=a19b484475ccf42fcde78a435834279e4247676b;hb=dcedf147ddcb6c21768cea94a2f06b93007d2a82;hpb=e2a4d830dd9817f6a515a3b1b6aa152d3bb98c2b diff --git a/TargetMouseBtn.m b/TargetMouseBtn.m deleted file mode 100644 index a19b484..0000000 --- a/TargetMouseBtn.m +++ /dev/null @@ -1,51 +0,0 @@ -// -// TargetMouseBtn.m -// Enjoy -// -// Created by Yifeng Huang on 7/27/12. -// - -#import "TargetMouseBtn.h" - -@implementation TargetMouseBtn - -+ (NSString *)serializationCode { - return @"mbtn"; -} - -- (NSDictionary *)serialize { - return @{ @"type": @"mbtn", @"button": @(_button) }; -} - -+ (Target *)targetDeserialize:(NSDictionary *)serialization - withMappings:(NSArray *)mappings { - TargetMouseBtn *target = [[TargetMouseBtn alloc] init]; - target.button = [serialization[@"button"] intValue]; - return target; -} - --(void) trigger { - CGFloat height = NSScreen.mainScreen.frame.size.height; - NSPoint mouseLoc = NSEvent.mouseLocation; - CGEventType eventType = (_button == kCGMouseButtonLeft) ? kCGEventLeftMouseDown : kCGEventRightMouseDown; - CGEventRef click = CGEventCreateMouseEvent(NULL, - eventType, - CGPointMake(mouseLoc.x, height - mouseLoc.y), - _button); - CGEventPost(kCGHIDEventTap, click); - CFRelease(click); -} - --(void) untrigger { - CGFloat height = NSScreen.mainScreen.frame.size.height; - NSPoint mouseLoc = NSEvent.mouseLocation; - CGEventType eventType = (_button == kCGMouseButtonLeft) ? kCGEventLeftMouseUp : kCGEventRightMouseUp; - CGEventRef click = CGEventCreateMouseEvent(NULL, - eventType, - CGPointMake(mouseLoc.x, height - mouseLoc.y), - _button); - CGEventPost(kCGHIDEventTap, click); - CFRelease(click); -} - -@end