Browse Source

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.
v7.0.9
reuk 2 years ago
parent
commit
081b1ff216
No known key found for this signature in database GPG Key ID: FCB43929F012EE5C
1 changed files with 5 additions and 4 deletions
  1. +5
    -4
      modules/juce_gui_basics/menus/juce_PopupMenu.cpp

+ 5
- 4
modules/juce_gui_basics/menus/juce_PopupMenu.cpp View File

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


Loading…
Cancel
Save