I just met with Quartz Event Taps, which basically allows you to capture a mouse event and execute your own callback.
I havenโt tried it myself, but it looks like you should check where you clicked the mouse and conditionally execute on the values
Here is an example :
//--------------------------------------------------------------------------- CGEventRef MouseTapCallback( CGEventTapProxy aProxy, CGEventType aType, CGEventRef aEvent, void* aRefcon ) //--------------------------------------------------------------------------- { if( aType == kCGEventRightMouseDown ) NSLog( @"down" ); else if( aType == kCGEventRightMouseUp ) NSLog( @"up" ); else NSLog( @"other" ); CGPoint theLocation = CGEventGetLocation(aEvent); NSLog( @"location x: %dy:%d", theLocation.x, theLocation.y ); return aEvent; } //--------------------------------------------------------------------------- - (void)applicationDidFinishLaunching:(NSNotification *)aNotification //--------------------------------------------------------------------------- { CGEventMask theEventMask = CGEventMaskBit(kCGEventRightMouseDown) | CGEventMaskBit(kCGEventRightMouseUp); CFMachPortRef theEventTap = CGEventTapCreate( kCGSessionEventTap, kCGHeadInsertEventTap, 0, theEventMask, MouseTapCallback, NULL ); if( !theEventTap ) { NSLog( @"Failed to create event tap!" ); } CFRunLoopSourceRef theRunLoopSource = CFMachPortCreateRunLoopSource( kCFAllocatorDefault, theEventTap, 0); CFRunLoopAddSource( CFRunLoopGetCurrent(), theRunLoopSource, kCFRunLoopCommonModes); CGEventTapEnable(theEventTap, true); }
rapidex
source share