If you're inside an application, which you presumably are since you have an IBAction method there, then the application is already invoking CFRunLoopRun (or equivalent); you don't usually want to recursively invoke it. If you simply return from -createTap:, the application's event loop will continue and will dispatch events to your cgEventCallback() as well as all the other event-handling routines necessary for the app to function. In general, you'll only need to call CFRunLoopRun() yourself if you've written a command-line tool or something similar that doesn't already have a run loop. There's probably a highlevel introduction to CF/NSRunLoops in the Conceptual Documentation part of the developer docs somewhere which will give you all the details you need.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list (Quart...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/quartz-dev/quartz-dev-garchive-50095%40googlegroups.com
This email sent to quartz-dev-g...@googlegroups.com
You shouldn't be calling CFRunLoopRun. A Cocoa app's main thread
already has a run loop that is running, courtesy of NSApplicationMain.
> =================
>
>
>
>
> CGEventRef cgEventCallback(CGEventTapProxy proxy, CGEventType type,
> CGEventRef event, void *refcon)
> {
> NSLog(@"cgEventCallback");
>
>
> int leftMouse = 0, rightMouse = 0;
> if (type == kCGEventLeftMouseDown) leftMouse = 1;
> if (type == kCGEventRightMouseDown) rightMouse = 1;
> if ( leftMouse || rightMouse)
> {
> NSLog(@"MOUSEDOWN");
> }
> return event;
> }
>
> - (IBAction)createTap:(id)sender
> {
> if([m_listnumberOfSelectedRows] == 1)
> {
> m_machPortRef= CGEventTapCreate(kCGHIDEventTap, kCGHeadInsertEventTap,
> 0,kCGEventLeftMouseDown, cgEventCallback, NULL);
> if(m_machPortRef)
> {
> CFRunLoopSourceRefrunLoopSource =
> CFMachPortCreateRunLoopSource(kCFAllocatorDefault, m_machPortRef, 0);
> CFRunLoopAddSource(CFRunLoopGetMain(), runLoopSource,
> kCFRunLoopCommonModes);
> CGEventTapEnable(m_machPortRef, true);
> CFRunLoopRun();
> }
> }
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Quartz-dev mailing list (Quart...@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/quartz-dev/jamesw%40frameforge3d.com
>
> This email sent to jam...@frameforge3d.com
--
James W. Walker, Innoventive Software LLC
<http://www.frameforge3d.com/>
-db