From af830046e96c10133bfb95f19ed00d07b888c77d Mon Sep 17 00:00:00 2001 From: Ian Harrigan Date: Sat, 6 Apr 2024 11:48:34 +0200 Subject: [PATCH] mouse must be over menu to enable cancellable event --- haxe/ui/containers/menus/MenuBar.hx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/haxe/ui/containers/menus/MenuBar.hx b/haxe/ui/containers/menus/MenuBar.hx index 667582aef..e4d93d2a3 100644 --- a/haxe/ui/containers/menus/MenuBar.hx +++ b/haxe/ui/containers/menus/MenuBar.hx @@ -232,11 +232,9 @@ private class Events extends haxe.ui.events.Events { return; } } - if (!force) { + if (!force && _currentMenu.hitTest(Screen.instance.currentMouseX, Screen.instance.currentMouseY)) { 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]; - } + beforeCloseEvent.relatedComponent = _currentMenu.findComponentsUnderPoint(Screen.instance.currentMouseX, Screen.instance.currentMouseY, MenuItem)[0]; _menubar.dispatch(beforeCloseEvent); if (beforeCloseEvent.canceled) { return;