diff --git a/haxe/ui/containers/menus/MenuBar.hx b/haxe/ui/containers/menus/MenuBar.hx index c1be71f4e..667582aef 100644 --- a/haxe/ui/containers/menus/MenuBar.hx +++ b/haxe/ui/containers/menus/MenuBar.hx @@ -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;