On Aug 21, 2012, at 6:33 AM, Jean Suisse <jean.li...@gmail.com> wrote:
> In short : > Is there a way to be notified of any change in the status of control keys > (option, control, command, etc.) in a given NSWindowController, when another > window of the app has the focus ? > > Long version (what I am trying to achieve) : > The app I am currently working on is a multipurpose data acquisition software > for scientists. > To make it simple, let's say the app has two windows. One main window in > which tasks are created and configured, one small HUD-window in which the > user can see all created and scheduled tasks (pending execution). > > On the HUD window, tasks can be altered (started, stopped, removed, etc…) by > means of appropriate buttons and pressing the option key while clicking on > one of these buttons can modify the action (e.g. pressing option while > clicking on the cancel will cancel all tasks instead of only the current > task). > > Currently, I am using > > -(void)flagsChanged:(NSEvent *)theEvent > > in the NSWindowController to display the appropriate text/image on the button > (so that the user knows which action will be executed upon hitting the > button). > > The issue : > When the main window of the application (or any other window but the HUD > panel) has the focus, hitting the option key will not change the text on the > panel button, since the panel will never get the event. However, clicking on > one of the panel button will activate the panel and execute the right action > (depending on the status of the option key). In this particular situation, > the text/image displayed on the button does not match the executed action. > > Question: > How can I catch app-wide flagsChanged events to always have my buttons > display the appropriate text / image ? See the Cocoa Event Handling Guide, particularly the section on Monitoring Events: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/MonitoringEvents/MonitoringEvents.html A local event monitor with the proper mask (NSFlagsChanged) should provide what you want. _______________________________________________ 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