Skip to content

Commit 5190e75

Browse files
committed
allow for an edge case where menu could have been destroyed
1 parent 34a5c9e commit 5190e75

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

haxe/ui/containers/menus/Menu.hx

+8
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,15 @@ class MenuEvents extends haxe.ui.events.Events {
175175
var event = new MenuEvent(MenuEvent.MENU_SELECTED);
176176
event.menu = _menu;
177177
event.menuItem = item;
178+
// we'll add a delay of 100ms here because it "feels nicer" for the menu to
179+
// not just instantly disappear - especially in the case of checkbox menu items
178180
Timer.delay(function() {
181+
// however, its possible that by the time that timer has ticked the menu
182+
// has already been destroyed by other means, so lets just make sure
183+
// that isnt the case
184+
if (@:privateAccess _menu._destroyed) {
185+
return;
186+
}
179187
findRootMenu().dispatch(event);
180188

181189
if (_menu.menuBar == null) {

0 commit comments

Comments
 (0)