Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Item in submenu of pop-up button's menu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Item in submenu of pop-up button's menu



On Thu, 27 May 2004 11:19:11 -0400, Laurence Harris <email@hidden>
wrote:
> On 5/27/04 7:42 AM, David Duncan didst favor us with:
>> On May 27, 2004, at 06:47 AM, Robert Purves wrote:
>>> Any suggestions?
>>
>> It really sounds like you need a new control. The popup button was
>> never really designed to handle sub-menus, so I know of no facilities
>> to deal with it. I don't know if a Bevel button with menu can do it,
>> but if you can tell us about the interface your trying to create there
>> may be other options that are easier to deal with.
>
> Agreed. Submenus in pop-up menus is generally discouraged because they
> result in an interface which is harder to navigate. Submenus in popup
> buttons are particularly problematic because ideally the button should
> display the current choice, which isn't possible if the last item was in a
> submenu.
>
> I agree with David that you should consider alternatives to this popup, but
> if you're bound and determined to do it this way, use menu commands instead
> of relying on item numbers.

I agree with Larry & David. You should "re-think" your GUI.

Once upon a time (in a galaxy far, far away (Cupertino, CA!)) I wanted to
add a rendezvous client menu to an applications preferences dialog. I wrote
the code at home where it listed 6 items to choose from. Everything was
good. God (ok, George) rested. Then I took it to work and there were 2476
items to pick from. OUCH! The dialog wasn't mine so I didn't have the option
of changing to a list but that 2476 item menu list was just unwieldy. So I
wrote a hierarchical menu stuffer that limited the number of items in any
single (hierarchical or not) menu to 32 items.

Up to 32 items == one menu
Up to 32^2 items == up to 32 menus of up to 32 items each.
Up to 32^3 items == up to 32 menus of 32 menus of up to 32 items each.
Etc.

I filled these "bottom up": (64 items went into 2 sub-menus, etc.)

So now the hard part. How do you name the intermediate menus so the user
knows how to navigate to find something? I had it somewhat easy that the
rendezvous names were sorted alphabetically, I only need to come up with a
descriptor that denoted the range of items below that menu. This code used
that last item from the previous menu with the first item of the current
menu to generate the minimal number of characters to make those two strings
unique. The same thing was done for the last item to generate the range. The
end result was something like

"Apple - Cat" => "Apple"
...
"Cat"
"Carrot - Lemon" => "Car"
...
"Lemon"
"Moon - Pubs" => "Moon"
...
"Pubs"

Done! (I was so proud!) BUZZZZZZ! Wrong answer! Like the gentlemen above
pointed out, the pop-up didn't reflect my choice! (After all that work!). So
what did I do? I cheated! Once I knew the users choice I deleted all the
menu's and set the pop-up to have one item, the one chosen. If the user
clicked the mouse again then I rebuilt the menu (the code was very fast,
never took more than some fraction of a second).

Done! (Ship it!)

--
Enjoy,
George Warner,
Schizophrenic Optimization Scientists
Apple Developer Technical Support (DTS)
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.