Re: NSPopupUpButton not showing checked menu items
Re: NSPopupUpButton not showing checked menu items
- Subject: Re: NSPopupUpButton not showing checked menu items
- From: Peter Ammon <email@hidden>
- Date: Mon, 24 Nov 2008 13:35:36 -0800
On Nov 24, 2008, at 1:21 PM, Steve Christensen wrote:
On Nov 24, 2008, at 12:53 PM, Peter Ammon wrote:
On Nov 23, 2008, at 3:33 PM, Steve Christensen wrote:
On Nov 23, 2008, at 3:05 PM, Kyle Sluder wrote:
On Sun, Nov 23, 2008 at 6:01 PM, Steve Christensen
<email@hidden> wrote:
The class methods also don't make a distinction between popup
and pulldown,
so I would think that the "selection" should still be marked in
the menu
when it's visible. I'm not trying to be argumentative, just
wondering if I
have, in fact, made a good or bad assumption about behavior
given how every
other menu I've seen works. I suppose I could manually set the
individual
menu item states but that seems like work I shouldn't need to do.
I think you have made a bad assumption. The selection bindings for
NSPopupButton consist of selectedIndex, selectedObject,
selectedTag,
and selectedValue. In order to support multiple selected items,
NSPopupButton would need a selectionIndexes binding.
Actually, I only wanted to select a single item in the pulldown
case, the same as what correctly happens for me in the popup case.
The problem has always been that, even though the button itself is
reporting that a particular item is "selected," none of the
underlying NSMenuItems' state is ever set to anything other than
where it was left in IB (which is typically NSOffState). And so a
check mark is never set next to the most-recently selected menu
item.
Pull-down popups are used for commands, like a context menu, and
therefore pull-down popups do not change the state of the selected
item. This is by design, since the commands are assumed to be
stateless. If you want to change the state of the menu item, you
can do so manually, but you might consider using a regular popup
button or a different control entirely. A pull-down popup that
acts like a matrix of radio buttons is a departure from Apple's HIG.
Well, I was specifically using the pulldown mode because I wanted a
control that would take up less space most of the time. In the
closed state, it's pretty much a button with a small icon
(reflecting the current option) and a down-arrow; clicking on the
button reveals a larger popup with a set of options.
I ended up setting and clearing checkmarks manually, which works
fine but was unexpected work. The NSPopUpButton class specifies both
methods and bindings for specifying the "selected item" regardless
of popup/pulldown control type. And since the API docs don't call
out any differences in behavior, I ended up wasting time trying to
figure out why my bindings weren't working "correctly."
Whether an item is selected is distinct from its state - see the
NSPopUpButtonCell method setAltersStateOfSelectedItem:. This setting
is always treated as false for pull-down popups.
It sounds like the docs aren't very clear on this. Please do file a
bug report for clarifying the documentation. Thanks!
-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