I have created a menu that has 3 simple entries and a submenu.
My menu is its own
VSTGUI::IControlListener and I have overriden the valueChanged() method, in order to check what item is selected and trigger some actions.
It works fine for the simple entries, but not for the submenu entries. Whenever I select an item from the submenu, I get in return the index of the last item selected from the main menu. How can I access the items from the submenu?
You can either add CCommandMenuItems to your menu and set its actions, or you can register an IOptionMenuListener on the menu and use the onOptionMenuSetPopupResult method.
I can confirm the same issue here too when migrating from VSTGUI 3.6 to 4.4.
Submenus worked fine in 3.6. In 4.4 clicking on the submenu returns wrong results and do not longer work. The tag assigned to the submenu is never called. Instead the tag of root menu is called with the index value of the submenu.
It’s a bug that affects all versions of VSTGUI4 (4.0 up to 4.11).
If was able to fix it.
The bug occurs since valueChanged() is called instead of lastMenu->valueChanged()
bool COptionMenu::popup ()
bool popupResult = false;
if (!getFrame ())
CBaseObjectGuard objGuard (this);
inPopup = true;
lastResult = -1;
lastMenu = 0;
getFrame ()->onStartLocalEventLoop ();
IPlatformOptionMenu* platformMenu = getFrame ()->getPlatformFrame ()->createPlatformOptionMenu ();
PlatformOptionMenuResult platformPopupResult = platformMenu->popup (this);
if (platformPopupResult.menu != 0)
IDependency::DeferChanges dc (this);
lastMenu = platformPopupResult.menu;
lastResult = platformPopupResult.index;
popupResult = true;
CCommandMenuItem* commandItem = dynamic_cast<CCommandMenuItem*>(lastMenu->getEntry (lastResult));
inPopup = false;