1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

PopupMenu: Always attach a global mouse listener

This makes behaviour more consistent between the parented and
non-parented display modes.

Before this change, parented popup menus wouldn't respond to mouse
clicks until the mouse was released once, which meant that clicking and
dragging the mouse over a menu wouldn't trigger a menu item on mouse-up.
This commit is contained in:
reuk 2025-03-03 13:42:06 +00:00
parent b0d7bad5ee
commit 51b0319342
No known key found for this signature in database

View file

@ -375,10 +375,13 @@ struct MenuWindow final : public Component
addToDesktop (ComponentPeer::windowIsTemporary
| ComponentPeer::windowIgnoresKeyPresses
| lf.getMenuWindowFlags());
Desktop::getInstance().addGlobalMouseListener (this);
}
// Using a global mouse listener means that we get notifications about all mouse events.
// Without this, drags that are started on a button that displays a menu won't reach the
// menu, because they *only* target the component that initiated the drag interaction.
Desktop::getInstance().addGlobalMouseListener (this);
if (options.getParentComponent() == nullptr && parentWindow == nullptr && lf.shouldPopupMenuScaleWithTargetComponent (options))
if (auto* targetComponent = options.getTargetComponent())
scaleFactor = Component::getApproximateScaleFactorForComponent (targetComponent);