Re: NSPopUpButton in toolbar ignoring setEnable: on Leopard
Re: NSPopUpButton in toolbar ignoring setEnable: on Leopard
- Subject: Re: NSPopUpButton in toolbar ignoring setEnable: on Leopard
- From: Peter Ammon <email@hidden>
- Date: Thu, 24 Jan 2008 17:32:44 -0800
On Jan 24, 2008, at 5:05 PM, Richard Pollock wrote:
My app has an NSPopUpButton and an NSSearchField in the toolbar,
which (I think) are misbehaving...
On Tiger, the controls were each placed in their own custom view in
their disabled state (by unchecking "Enabled" in IB) and added to
the toolbar by my NSDocument subclass in -
toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:. The
controls were enabled later by calling [myNSControl
setEnabled:TRUE]. This worked fine on Tiger.
After moving to Leopard, these controls stopped activating when -
setEnabled:TRUE was called. As a temporary fix, I just enabled them
permanently in IB, but today I took the liberty of removing all my
NSToolbar delegate methods and rebuilding the toolbar in IB (I'm
going Leopard-only). This has been successful except for the
problem of activating my NSPopUpButton and NSSearchField at run
time, which I just can't seem to achieve.
I added the controls directly to the toolbar from the palette in
IB, connected the appropriate outlets and actions, which has worked
- the NSPopUpButton menu populates correctly, but remains inactive.
I've also tried to call -setEnabled:TRUE on the NSToolbarItem
containing the the NSPopUpButton followed by -setEnabled:TRUE on
the NSPopUpButton itself, but all to no avail. Finally, I've set my
NSDocument subclass up as the delegate again and implemented -
validateToolbarItem: to return TRUE regardless of the item...
So basically, my question is: am I doing anything wrong here? The
toolbar programming guide says "If the view is an NSControl you can
call setEnabled:, which will in turn call setEnabled:on the
control", so I don't know why it's not working in my hands... Any
pointers (no pun intended) would be most appreciated!
Hi Rich,
NSToolbarItem, like NSMenuItem, validates against its target, not its
delegate; or if the toolbar item has no target, against the first
responder in the responder chain that implements the toolbar item's
action.
But none of that should matter for a toolbar item with a custom view,
which by default does nothing in validate. What I would do in your
case is put a breakpoint on setEnabled: and see where, exactly, the
view is getting disabled, or if it is even getting enabled. You
might subclass your NSPopUpButton to make it easier to catch
setEnabled: calls on just that control.
Hope that helps,
-Peter
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden