Modifying Popup Menu (from System Tray Icon) with Alt Key

I made an application that mostly lives in the system tray, and on clicking the icon it shows a popup menu.

I was trying to re-create the common macOS behaviour and display some advanced options when the “alt” key is held down, but somehow i couldn’t make my SystemTrayIconComponent to receive any key events.

I implemented the KeyListener interface and registered it with the SystemTrayIconComponent as well as the toplevel component, and tried to acquire keyboard focus, but to no avail.

Is there a way to make a SystemTrayIconComponent receive key press events ?


Look at how the DemoRunner does things:

struct DemoTaskbarComponent  : public SystemTrayIconComponent,
                               private Timer
        setIconImage (getImageFromAssets ("juce_icon.png"),
                      getImageFromAssets ("juce_icon_template.png"));
        setIconTooltip ("JUCE demo runner!");

    void mouseDown (const MouseEvent& e) override
        if (e.mods.isAltDown())

1 Like

I settled for a similar solution, but the one behaviour i couldn’t reproduce (and which some menus in macOS, esp. in Finder, show) is to modify the content of a menu that is already shown.