Browse Source

PopupMenu: Fix click-through from submenu

Previously it was possible to inadvertently activate a menu item by
clicking on a submenu item that was drawn on top of the parent menu.

The root cause was that hide() initiates an asynchronous mechanism
through exitModalState() that eventually destroys the MenuWindow, but
the MouseSourceState timer callbacks and event handlers sometimes still
had a chance to do a state update. Since the submenus have just been
destroyed the update could mistakenly conclude to activate one of the
items of the now lone parent.
v6.1.6
attila 3 years ago
parent
commit
a1a8e1339f
1 changed files with 5 additions and 0 deletions
  1. +5
    -0
      modules/juce_gui_basics/menus/juce_PopupMenu.cpp

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

@@ -541,6 +541,7 @@ struct MenuWindow : public Component
auto resultID = options.hasWatchedComponentBeenDeleted() ? 0 : getResultItemID (item);
exitModalState (resultID);
exitingModalState = true;
if (makeInvisible && deletionChecker != nullptr)
setVisible (false);
@@ -739,6 +740,9 @@ struct MenuWindow : public Component
if (! treeContains (currentlyModalWindow))
return false;
if (exitingModalState)
return false;
return true;
}
@@ -1323,6 +1327,7 @@ struct MenuWindow : public Component
uint32 windowCreationTime, lastFocusedTime, timeEnteredCurrentChildComp;
OwnedArray<MouseSourceState> mouseSourceStates;
float scaleFactor;
bool exitingModalState = false;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MenuWindow)
};


Loading…
Cancel
Save