Selectable sub-menus?

OK, how would one go about having menu items that are both sub-menu containers and selectable items in their own right?

The only way I can see to do this is to make a completely custom menu component, have it masquerade as a normal menu item, but also as a sub menu container. Then catch sub-menu selections and trigger them as its own. This leads to two problems:

  1. The menu IDs of the child items are not guaranteed to be unique with respect to the ‘main’ menu tree. The constructor could return a count of used IDs I guess. This seems cumbersome though.

  2. The custom component is not owned by the menu. This is a pain in that in my particular case, this is a context sensitive menu that is being built up by a number of different methods. As such I don’t really want to encumber calling methods with the job of knowing about child components that may have been created by other methods.

Is there a better way of going about this, or:

  • could either addSubMenu be extended to also allow clicking and a return ID (this would be cleaner).
  • addCustomItem() for raw components be modified to optionally also take ownership of passed components.

I’d have to extend it to do that, really (it’s probably not too difficult to add). What kind of thing are you trying to do? I’ve never really seen the need for this.

And although I’ve seen this done on windows, I’m not sure that you’d ever see this done on a mac.

This is a cleaned up description of my specific need - the particulars are app specific and too involved to go into.

Imagine a component has a set of attributes. These attributes are logically related. A context popup makes them accessible as a subfolder full of tick options. In some cases (mine for example) it might be useful if selecting the sub-menu item could act as a short-cut for clear-all/set-all for those child tick option menu items.

Hmm. Not sure I’d find that very intuitive. Wouldn’t it be better to just stick a couple of menu items at the bottom that actually say select/deselect all?

I guess such a feature could also be used to select a ‘default’ item from the submenu. It’d probably need some kind of indicator though so it looked like it could be clicked.

Still, I personally agree with Jules in that it doesn’t sound like it’d be particularly intuitive, though I guess how ‘obvious’ it’d be might depend entirely on just how logically grouped the attributes are; sometimes all it takes is choosing exactly the right word to envelop a collection of objects or actions for its use and purpose to be perfectly clear. And of course sometimes of course it just needs the right symbol or indicator on it.

right, so the shortish story:

(I’ll use a real world example to illustrate the concept)

Think of those Windows installers with the tree list of installable elements. There might be a main “Application” option, and a “Big Assed Toolkit” option. These options can typically either be toggled on or off, depending on whether one wants to install the component in question.

Additionally the items can be expanded to show sub items that can selectively be installed, I.E. “Big Assed Toolkit” may comprise: “Flubber Doohickey” and “Advanced Easy Wibble Editor”. These can optionally be turned on or off as standard check options.

When all child items are selected, “Big Assed Toolkit” will be shown will a full selection glyph. If only some of the child components are selected, it will be shown with a partial glyph. Otherwise it’ll be shown cleared.

In my case, I have a similar kind of setup. Only I’m allowing my users to quickly toggle some flags via a right-click context. There is a far larger and more elegant interface elsewhere - this is for the power users who need to be able to toggle these settings quickly.

My implementation uses a custom tick glyph that is rendered in either black or silver to denote selection or partial selection of child items. This glyph is applied to the sub-menu element to make it look like a tick item. By providing this tick graphic, I think it would be pretty intuitive to most of my users that the parent menu itself can be toggled, just like the child sub-menu items.

Ok, point taken. Can’t say when I’ll have time to try adding this, but I’ll add it to the list.

Hi Jules,

How can I go about implementing a combobox or pop up menu in which multiple items can be selected, and the selected items checked or highlighted?

There are probably people reading this forum who weren't yet born when this original thread was started!

A ComboBox can only have one item selected because that's just how they work. But all items in a PopupMenu can be either ticked or unticked - it's up to your own code to decide which ones you want to tick!