Re: One more NSToolbar question
Re: One more NSToolbar question
- Subject: Re: One more NSToolbar question
- From: Chuck Pisula <email@hidden>
- Date: Wed, 9 May 2001 10:47:02 -0700
You should hook up the show/hide to the NSWindow your toolbar is in.
Doing this will allow the window to be the guy to validate the menu item.
If you really need to handle the show hide yourself, you'll have to do
your own validation.... or possibly just forward on that part of your
validation code to the window!
-c
On Tuesday, May 8, 2001, at 06:19 PM, Matt Ridley wrote:
Hi folks,
I've been reading the AppKit release notes; specifically the section on
NSToolbar; and I saw the following text:
A couple of methods have been added to NSWindow to help support
NSToolbar. NSWindow now lets you add a toolbar, show/hide the current
toolbar, and run the customization palette. If you add menu items in
your application and hook them up to toggleToolbarShown:, and
runToolbarCustomizationPalette: NSWindow will take care of validation.
In particular, the menu item with toggleToolbarShown: as its action will
properly title the menu item dependent on the current state of the
toolbar.
This is all true enough (I see it in NSWindow.h), but those actions aren'
t listed in Interface Builder when I control-drag from my "Hide/Show
Toolbar" menu item to my window. Thus, I'm unclear as to how to specify
toggleToolbarShown: as the action for my menu item.
Currently, I have a ToolbarController class which takes care of all
processing related to my NSToolbar. It has two custom actions, one of
which is showHideToolbar:. In my implementation for showHideToolbar:, I
simply do this:
[toolbarWindow toggleToolbarShown:sender];
This has the desired effect of hiding/showing the toolbar in the endorsed
way (highlighting the toolbar widget at the right of the titlebar as it
does so), but it does NOT automatically change the title of my "Hide/Show
Toolbar" menu item. I'm presuming that if I could somehow directly
specify toggleToolbarShown: as the action for my menu item (in Interface
Builder), that it would then take charge of the title of my menu item,
and make it either "Hide Toolbar" or "Show Toolbar" as appropriate. But,
as I said, Interface Builder doesn't seem to know about that action.
Any help would be much appreciated. It's a minor cosmetic problem, but I'
d like my menu item not to always just say "Hide/Show Toolbar" - that's
quite clumsy. Thanks once again. :-)
Best,
-Matt
--
Matt Ridley
<http://www.mattridley.com/>
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev