Re: NSPopUpButton is too smart for it's own good
Re: NSPopUpButton is too smart for it's own good
- Subject: Re: NSPopUpButton is too smart for it's own good
- From: "Erik M. Buck" <email@hidden>
- Date: Thu, 7 Feb 2002 13:37:55 -0600
I would answer your question by observing that you do not want a
pop-up-button. You describe very specific behavior that is not the behavior
of a pop-up-button. If you make a control that looks like a pop-up-button
but behaves as you describe, I expect that users will be very confused. You
should not radically change the behavior of a user interface element but
make it look the same. Look and feel go together.
You need to create a new control and don't make it look like a
pop-up-button.
The behavior you want is so far from the expected behavior of a
pop-up-button that I would not suggest starting with a pop-up-button. Start
with NSButton or NSControl.
Actually, on second reading, it seems to me that what you want in a simple
NSMatrix with check boxes or possibly custom cells. Manage the order and
selection of the items within the matrix yourself. If you don't want it
visible all of the time, use a button to open a little modal window
containing the matrix. You can align the window with the button to make it
work like a pop-up-button. You can set the title of the button to whatever
you want.
----- Original Message -----
From: "Steve Bennett" <email@hidden>
To: <email@hidden>
Sent: Thursday, February 07, 2002 11:37 AM
Subject: NSPopUpButton is too smart for it's own good
>
Hi!
>
>
The topic of discussion today is NSPopUpButton. We're trying to move over
>
some behavior of an older Carbon app to Cocoa, and make it work fairly
close
>
to the old app. All very nice until we got to our Popup control, and
>
discovered that NSPopUpButton does a lot of work for you. Unfortunately,
>
it's work we *don't* want, and can't figure out how to turn off. I turn
>
here to see if anyone has good answers for these issues. I'm going to
cover
>
each problem area seperately. There are good reasons for doing each thing
>
described, but if I go into them this message will get *really* long, so
>
just take each item as a given.
>
>
1) We prefer to use the Popup style, not the Drop down style. This isn't
>
really a problem, although using the Drop down style might fix one of our
>
issues. We use Popup style because there's always a single item
>
selected/checked, and would like the menu to start on that item.
>
>
2) Items with the same name. The menu is constructed dynamically, and
quite
>
frequently there are items in the menu with the same exact name. These
come
>
from user defined values, which could match each other, or one of the
other
>
items in the menu. Selecting among these items has somewhat different
>
behavior depending on where they appear in the menu. (They end up with
>
different target/action settings...)
>
>
Unfortunately, the NSPopUpButton control assumes that if you add an item
>
into the menu with the same name as another item in the menu, you're
>
actually replacing that item. We've hacked around this for now by adding
>
stuff to the end of duplicate names, but that causes it's own issues.
>
>
3) Setting the title. Depending on the item selected, the title that
needs
>
to be displayed may or may not match the text of the menu item. (Some
items
>
bring up a sheet to get more info, and the title reflects the additional
>
info...) We use the setTitle method to change the title. This has a
bunch
>
of side effects:
>
>
- When we select an item, it overwrites our title. We tried overriding
the
>
synchronizeTitleAndSelectedItem method to make it do nothing, but it
wasn't
>
very effective.
>
>
- When we call setTitle, it selects the item with that name in the menu,
>
which may not be what we want. (With our hack for #2, we have to be very
>
careful to set the title with the same additional stuff at the end, or it
>
will select the wrong item...)
>
>
- When we call setTitle and the name *isn't* in the menu, it sometimes
adds
>
a temporary menu item to the end of the menu with that name and selects
it.
>
>
Unfortunately, setTitle isn't documented yet, so it's not clear what it's
>
actually supposed to do. We *might* be able to fix some of this behavior
>
with a drop-down list, but I'm not certain.
>
>
Anyone have suggestions on how to get this control to stop doing what it
>
thinks I want, and does only what I tell it to?
>
>
-->Steve Bennett
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.