Re: Toggle between Alternate Menus
Re: Toggle between Alternate Menus
- Subject: Re: Toggle between Alternate Menus
- From: Scott Stevenson <email@hidden>
- Date: Sun, 3 Oct 2004 23:15:35 -0700
On Oct 3, 2004, at 1:54 AM, Georg Tuparev wrote:
here is what I did:
1. Created 2 menus (Hide Bla and Show Bla) - no key equivalents, only
Show bla has an extra key modifier. [As expected, when the app runs,
only Hide Bla is visible and enabled]
2. Added a toggleBlaShow: to the first responder, and set it as an
action to both menu items.
3. Implemented toggleBlaShow somewhere in the responder chain
(probably here I must add some magic - the question is what).
We talked off list a bit, but here's the gist:
The alternate menu functionality is for when you have a single command
that you want to work slightly differently if a modifier is held down.
For example, in the Apple menu there's an item that says "Log out
<Person>....". If you hold down Option while the menu is open you can
see that the ellipsis in the title goes away. This just means that
holding down option when you choose "log out" will disable the prompt.
I don't believe the alternate menu functionality is designed for a
"toggle" type of situation because you have to use an extra modifier to
get the alternate menu item. And toggle functionality should be
activated the same way regardless of the current state.
Nothing happens if I select the Show Bla with mouse, but exactly the
same works if I connect the menus to the NSWindow's toggleToolbarShow:
The reason is that NSWindow handles the toolbar menu item automatically:
"NSWindow validates both toolbar menu items and takes care of ensuring
that the
toggling between Hide Toolbar and Show Toolbar stays in sync with the
actual
state of the toolbar."
<
http://developer.apple.com/documentation/Cocoa/Conceptual/Toolbars/
Concepts/HowToolbarsWork.html>
In fact, you'll note that your menu item names are overridden by
NSWindow. You can call the menu item "Today is Sunday" and it will say
"Show Toolbar" when you it in IB's interface test mode.
- Scott
--
http://treehouseideas.com/
http://theobroma.treehouseideas.com/ [blog]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden