Popup submenu selection

Hi I’m trying to make a submenu, I’ve created it, and it looks fine.
The problem is returning what is selected, as I can’t distinguish between the main menu and a sub menu in the returning data as it’s only one ‘int’

	popupMenu.showMenuAsync(PopupMenu::Options().withTargetComponent(&presetBox),
				[](int v)
		{
		   // 'v' is the item selected, but from which menu?
		});

Thanks for any direction on this.

The returned int is the ID of the item in the PopupMenu. When you populate the menu, it is your responsibility to make sure, that the IDs are actually unique.
Best practice is to start each menu or submenu with a fixed offset, so you can easily distinguish later on.

1 Like

Doh! of course, there’s me thinking they’d be a sophisticated C++ way, but that’s much better, thanks. I presume it’s future proof? - Always a worry. :slight_smile:

Sure, since the IDs are always user provided.

Nice one Dan.

Just one thing, quickly. The button that opens the popup has a roll-over highlight. But this stays on as the mouse goes to the menu item, and never turns off until I go all the way back over it again. Is there a way of manually turning off the roll over effect? I need it to exist for plug-in consistency.

Do you mean the combo box field? I ran into the same issue, its “hover” effect hardly works. It should work like the button, but it doesn’t and it’s not usable.

No I mean the button I use to trigger the popup menu. It’s just an ImageButton setup like this:-

presetBox.setImages(true, true, false, presetOff, 1.0f, Colour(0x0), presetOff, 1.0f, Colour(0x20ffffff), presetOn, 1.0f, Colour(0x0));

mouse over uses the same graphic as off state but has a faint white tint when the mouse goes over it.
Unfortunately it the tint stays on even though my mouse has moved away, and it forgets it was even on until I go back.
I just tried calling presetBox.repaint() after the menu item has been chosen but it remains highlighted.

1 Like

mouseExit is not called on the button, and I can’t call updateState (false, false) as it’s private.
I presume mouseExit is not called because it enters the menu state.

1 Like

I’ve got it, finally. I have to set the button state manually when the popup closes by:-

	->presetBox.setState(ImageButton::buttonNormal);