PopupMenu CustomComponent with Button

Hi all,

I’ve got a PopupMenu for some audio samples, and I want to have an “audio sample preview” button next to each PopupMenu item so that a user may preview the audio of any sample in the PopupMenu list. This way, the user can look through the PopupMenu, previewing various samples with the preview buttons before they make their final selection and close the PopupMenu.

PopupMenu::CustomComponent seems like a great candidate for this. I could add a button to my new PopupMenu::CustomComponent so when the PopupMenu row is drawn it draws a Button in addition to the name of the audio sample.

But, I am having problems:

  • If I set PopupMenu::CustomComponent::triggeredAutomatically to true via the constructor, whenever I click the sample preview button contained in the PopupMenu::CustomComponent the corresponding PopupMenu item is selected and the PopupMenu is closed. When the audio sample preview button is clicked, I do not want the PopupMenu item to be selected, and I do not want the PopupMenu to close.

  • If I set PopupMenu::CustomComponent::triggeredAutomatically to false via the constructor, I can get the audio preview button to behave properly: when I click the audio preview button, the PopupMenu item is not selected, just as I want :+1:. But, keyboard navigation with the arrows/enter keys is broken. I can no longer use the arrow keys to move up and down between these custom menu items and I can no longer press enter to select a menu item.

Does anyone know a workaround for this problem?

Has anyone ever successfully added a Button to a PopupMenu::CustomComponent where that Button is not used to select the PopupMenu::Item, but is rather used for some other functionality, while ensuring that navigation through the PopupMenu using arrow keys still works?