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

PopupMenu: Avoid dismissing menu in response to mouse events over the menu

In cases where no JUCE component had keyboard focus, clicking a menu
item would cause the menu to be dismissed instead of triggering the
item's action.
This commit is contained in:
reuk 2023-03-29 19:33:53 +01:00
parent a7563b5e91
commit 081b1ff216
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -1407,7 +1407,9 @@ private:
&& (ModifierKeys::currentModifiers.isAnyMouseButtonDown()
|| ComponentPeer::getCurrentModifiersRealtime().isAnyMouseButtonDown());
if (! window.doesAnyJuceCompHaveFocus())
const auto reallyContained = window.reallyContains (localMousePos, true);
if (! window.doesAnyJuceCompHaveFocus() && ! reallyContained)
{
if (timeNow > window.lastFocusedTime + 10)
{
@ -1416,10 +1418,9 @@ private:
// Note: This object may have been deleted by the previous call.
}
}
else if (wasDown && timeNow > window.windowCreationTime + 250
&& ! (isDown || overScrollArea))
else if (wasDown && timeNow > window.windowCreationTime + 250 && ! isDown && ! overScrollArea)
{
if (window.reallyContains (localMousePos, true))
if (reallyContained)
window.triggerCurrentlyHighlightedItem();
else if ((window.hasBeenOver || ! window.dismissOnMouseUp) && ! isOverAny)
window.dismissMenu (nullptr);