PopupMenu::Options::withTargetComponent() makes a popup menu appear either above or below a component, could we get a flag to optionally make it appear beside? Like a sub menu would.
Closest work around I’ve found is to give withTargetScreenArea() an empty Rect, but I can’t control if the menu goes up or down so sometimes it looks weird.
Internally there is already a flag that does what I want, but it’s only set if the target area is empty, if you could expose it Options struct, that would be nice.
Also, is there a way to disable ComponentPeer::windowIgnoresKeyPresses() for PopupMenus? I want to add a custom component that responds to keyboard.
Having an option to disable ComponentPeer::windowIgnoresKeyPresses() would indeed be great. What i am trying to achieve at the moment is a custom menu item that changes title and action if a modifier is pressed (as common with mac software). I am stuck trying to intercept any key events if the popup doesn’t have a parent.
Here’s a workaround (it’s a bit ugly though).
In your LookAndFeel override preparePopupMenuWindow and re-add the MenuWindow to the desktop, without the windowIgnoresKeyPresses flag:
void MyLookAndFeel::preparePopupMenuWindow(Component& window)
{
if (!window.getParentComponent())
window.addToDesktop(ComponentPeer::windowIsTemporary | getMenuWindowFlags());
}