Button, stay down while your menu is up!

I want to implement the behavior, seen in XCode or the Finder for example, where buttons that bring up popup menus stay depressed while the menu is active.

My plugin calls showAt() from the button’s handler, just like the Juce widget demo. And while this thread is busy showing the menu, the button’s state is reset. That seems good.

But the only design that comes to mind for a button that does stay down, is a subclass of Button that knows about the state of an attached menu. That seems kind of ugly. Does anyone have a better idea?

I agree, I noticed that behavior in my own app and wanted to correct it. If you come up with something let me know.

It’s not the most general solution, but if you want to make one button look right with a modal menu or callout, just set

myButton->setTriggeredOnMouseDown (true); myButton->setClickingTogglesState(true);
then at the end of your menu method, call

myButton->setToggleState(false, false);