Display selected sub-menuItem in NSPopUpButton - menuitem

I have filled my NSPopUpButton with menu and submenus.
When I select a menuItem on the root menu (so, not a sub-menuItem), it propery displays the menuItem selected. And when I re-click on the popUp button, I get the selected menuItem under the mouse.
But if I select a sub-menuItem, it doesn't display it. And if I re-click on the popUp button, I don't get it under the mouse. Any time I click on the button, I have to look for the selected item diving in the menu hierarchy.
Any solution?

The Human Interface Guidelines state:
Avoid adding a submenu to an item in a pop-up menu. A submenu tends to
hide choices too deeply and can be physically difficult for users to
use.
I assume that since the practice is discouraged (albeit not that strongly) that it is not supported either. I can see how submenus would break some of NSPopUpButton's functionality, all of the item index related methods would not make sense. Those methods would have to use NSIndexPaths instead of simple indexes.
A potential substitute would be to use different indention levels in the menu to indicate hierarchy. I am about to try that myself.

Related

How to show drop-down list when set focus in ComboBox edit?

I want to implement auto-complete in ComboBox. As the first step, when a user clicks on the edit box and before typing anything, it should show the drop-down list with all available choices.
void ...::OnCbnSetfocus()
{
if (!GetDroppedState())
{
ShowDropDown(TRUE);
}
}
One issue is that if user clicks the drop-down button, the drop-down list appears and quickly disappears. To address that I think I need to subclass ComboBox to intercept the "click drop-down button" event and not pass it along the chain. But after some searching, I don't seem to find what event it is.

Nested comboboxes in Qt

I'm looking for a way of nesting comboboxes in my GUI application (or to be more precise, I'm looking for a way to have an item displaying similar visual and functionnal properties as nested comboboxes).
Looking first at all the functions provided by the combobox class, it seems comboboxes nesting it's not supported by Qt.
I therefore thought that another solution would be to create a "menu" item outside the menu bar. If I understand correctly this phrase from the offical Qt documentation, it seems to be feasiable :
A menu widget can be either a pull-down menu in a menu bar or a standalone context menu
Not sure though was is meant by the "context" word.
However, there is no such (menu) widget in Qt designer and I haven't found any good examples about how to do it on the internet (and can't get a menu not associated with a menu bar to be displayed on the windows), explaining why I'm currently doubting whether it's feasible or not with a menu item.
I would greaty appreciate if you could provide some code sample along your response.
EDIT :
To clarify my first post, I'm trying to do something similar to this app :
It's the application that comes along the 3D connexion mouse whose usage is to parametrize each button.
As you can see, there are several sub-menu items. By clicking on the arrow next to a textbox, you open a sub-menu containing itself folders that contains themselves paramaters.

QCombobox - hide first item on drop-down

Hello fellow developers!
I want to realize a "Action" QCombobox where the different options trigger an action instead of choosing an option. The combobox says something like "Add Property" and when the user clicks it, he gets the different properties to choose from. If the user clicks one of them, it is added to -whateverdoesntmatter-. The combobox than switches back to it's original state.
The problem is, that the first entry "Add Property" is shown on the combobox's drop down, causing a little bit of confusion for the user since it is not really an action.
Normal state:
[Add Property]
Drop-down state:
[Add Property]
Add Property
Length
Width
etc ...
Therefore, I want to hide the first option as soon as the combobox drops down to achieve this behavior:
[Add Property]
Length
Width
etc ...
I have already tried with subclassing the combobox and overwriting showPopUp() and hidePopUp() - but I could not figure out how to get my intended behavior.
Ideas? Thanks!
If you don't absolutely need a QComboBox you might be better/easier off using a QToolButton with a QMenu associated and then set the button's popupMode to an appropriate value.
You may even use a QToolBar. Simply add a QAction with your desired label (like Add Property), associate the menu to it via QAction::setMenu and at it to the toolbar. The toolbar will automatically create the tool buttons itself.
To access the popupMode property you can use QToolBar::widgetForAction and cast it to a QToolButton.

the combobox dropdown list is so small that an updown arrows appear beside it

I have comboboxes that was built on the OWL I moved them to MFC and I faced alittle problem, the dropdown list of the combobox is so short that it shows only one item and you can navigate to the other items by using udown arrows like in the picture
the image on the left shows the short and incorrect one, the one on the right shows the release version that is working well.
what can cause this problem? and hoe to fix it. think it is style issue
Open dialog template in Resource Editor. Select combobox by mouse. Click on the "Down Arrow" element in the right part of the combobox (in your case it may be left part, according to localization). Then resize the combo to required height - in this state it resizes dropdown list. Build application and test dropdown list height at runtime - it should be OK.
http://msdn.microsoft.com/en-us/library/vstudio/4cta1x1t.aspx
See also: CB_SETMINVISIBLE message - allows to resize dropdown list size programmatically. I have never use it in my programs, though, so this is just a hint.

MFC Menu Drop Down (Screenshot included)

I'm having difficulties with an MFC application menu drop down. I want the drop down to display all items when it is clicked. Instead it displays arrows which the user must click in order to show the drop down items.
See the pic below. Any help would be appreciated. Thanks!
I believe this is a feature of the MFC feature pack where the menu will hide rarely used items. You should be able to disable this feature using the CMFCMenuBar::SetShowAllCommands method.