5 // Created by Yifeng Huang on 7/27/12.
6 // Copyright (c) 2012 __MyCompanyName__. All rights reserved.
9 #import "TargetMouseBtn.h"
11 @implementation TargetMouseBtn
15 -(NSString*) stringify {
16 return [[NSString alloc] initWithFormat: @"mbtn~%d", which];
19 +(TargetMouseBtn*) unstringifyImpl: (NSArray*) comps {
20 NSParameterAssert([comps count] == 2);
21 TargetMouseBtn* target = [[TargetMouseBtn alloc] init];
22 [target setWhich: [[comps objectAtIndex:1] integerValue]];
27 NSPoint mouseLoc = [NSEvent mouseLocation];
28 CGEventType eventType = (which == kCGMouseButtonLeft) ? kCGEventLeftMouseDown : kCGEventRightMouseDown;
29 CGEventRef click = CGEventCreateMouseEvent(NULL,
31 CGPointMake(mouseLoc.x, mouseLoc.y),
33 CGEventPost(kCGHIDEventTap, click);
38 NSPoint mouseLoc = [NSEvent mouseLocation];
39 CGEventType eventType = (which == kCGMouseButtonLeft) ? kCGEventLeftMouseUp : kCGEventRightMouseUp;
40 CGEventRef click = CGEventCreateMouseEvent(NULL,
42 CGPointMake(mouseLoc.x, mouseLoc.y),
44 CGEventPost(kCGHIDEventTap, click);