Skip to content

Commit

Permalink
allow before_close to be cancelled at the menubar level
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Apr 6, 2024
1 parent f9c2db4 commit 9117c16
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions haxe/ui/containers/menus/MenuBar.hx
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,16 @@ private class Events extends haxe.ui.events.Events {
return;
}
}
if (!force) {
var beforeCloseEvent = new UIEvent(UIEvent.BEFORE_CLOSE);
if (_currentMenu.hitTest(Screen.instance.currentMouseX, Screen.instance.currentMouseY)) {
beforeCloseEvent.relatedComponent = _currentMenu.findComponentsUnderPoint(Screen.instance.currentMouseX, Screen.instance.currentMouseY, MenuItem)[0];
}
_menubar.dispatch(beforeCloseEvent);
if (beforeCloseEvent.canceled) {
return;
}
}

var menuEvent = new MenuEvent(MenuEvent.MENU_CLOSED);
menuEvent.menu = _currentMenu;
Expand Down

0 comments on commit 9117c16

Please sign in to comment.