|Managing Menu Item Enable State [message #663138]
||Mon, 04 April 2011 02:09
| Doug M
Registered: December 2009
Hi all. I want to enable/disable the File->Save menu item, depending on whether the document is dirty. MenuShown() in a MenuListener on the File menu seemed the perfect way to do this. It is called before the menu drops down, checks the front document state, and enables or disables the Save item as appropriate.|
All would be well except that Save also must have the standard cmd-S shortcut. The MenuListener is *not* called when cmd-S is typed, therefore the Save menu item is selected when not appropriate (with menu blinking), and vice versa.
Is there some listener or method I am not aware of that can nicely work around this functional inconsistency?
I know I could have every place that dirties the document set the menu item's state. However, setting the state in the UI menu handler seems like the clear and clean way to handle this behavior. Besides when (someday) SWT allows a single menubar on OS X, you would have to start messing with the menus whenever a different document is brought to front.
FWIW, OS 9, OS 10, and Windows all have ways of notifying the application that a command key is about to be searched for in the menus, exactly so that the app can set the correct menu state.
Thanks in advance for ideas.
Powered by FUDForum
. Page generated in 0.01919 seconds