I wanted to show a hidden menu item in the Window menu when the option key is 
pressed. 
Similar to the way the Finder's Go menu behaves with the user Library menu 
item. 

I was able to use the NSMenu delegate methods to do this by using a CGEventTap 
creating or re-enabling the tap in menuWillOpen: and disabling the tap in 
menuDidClose:
This works well and the callback calls a method ( with some void* bridging to 
the app delegate object ) to set the menu item hidden and enabled states and 
update the menu. 

However, I also tried and failed with NSEvent global and local monitors. 

So, I have a few remaining questions. 

Do menus receive events before the application itself?

Is there a better way to do this? It feels like using a sledgehammer for a 
butter knife. 

Would this be sandbox compliant at all?

Thanks
JJ

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to