Skip to content

Commit

Permalink
allow for an edge case where menu could have been destroyed
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Sep 1, 2024
1 parent 34a5c9e commit 5190e75
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions haxe/ui/containers/menus/Menu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,15 @@ class MenuEvents extends haxe.ui.events.Events {
var event = new MenuEvent(MenuEvent.MENU_SELECTED);
event.menu = _menu;
event.menuItem = item;
// we'll add a delay of 100ms here because it "feels nicer" for the menu to
// not just instantly disappear - especially in the case of checkbox menu items
Timer.delay(function() {
// however, its possible that by the time that timer has ticked the menu
// has already been destroyed by other means, so lets just make sure
// that isnt the case
if (@:privateAccess _menu._destroyed) {
return;
}
findRootMenu().dispatch(event);

if (_menu.menuBar == null) {
Expand Down

0 comments on commit 5190e75

Please sign in to comment.