Skip to content

Commit

Permalink
menus dont need to hide themselves when associated with a menubar
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Apr 6, 2024
1 parent af83004 commit b44e521
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
22 changes: 13 additions & 9 deletions haxe/ui/containers/menus/Menu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class Menu extends Box {
@:behaviour(CurrentIndexBehaviour, 0) public var currentIndex:Int;
@:behaviour(CurrentItemBehaviour) public var currentItem:MenuItem;

public var menuBar:MenuBar = null;

/**
Utility property to add a single `MenuEvent.MENU_SELECTED` event
**/
Expand Down Expand Up @@ -171,16 +173,18 @@ class MenuEvents extends haxe.ui.events.Events {
event.menu = _menu;
event.menuItem = item;
findRootMenu().dispatch(event);

var beforeCloseEvent = new UIEvent(UIEvent.BEFORE_CLOSE);
beforeCloseEvent.relatedComponent = item;
findRootMenu().dispatch(beforeCloseEvent);
if (beforeCloseEvent.canceled) {
return;
}

hideMenu();
removeScreenMouseDown();
if (_menu.menuBar == null) {
var beforeCloseEvent = new UIEvent(UIEvent.BEFORE_CLOSE);
beforeCloseEvent.relatedComponent = item;
findRootMenu().dispatch(beforeCloseEvent);
if (beforeCloseEvent.canceled) {
return;
}

hideMenu();
removeScreenMouseDown();
}
_menu.dispatch(new UIEvent(UIEvent.CLOSE));
}
}
Expand Down
1 change: 1 addition & 0 deletions haxe/ui/containers/menus/MenuBar.hx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ private class Events extends haxe.ui.events.Events {
return;
}

menu.menuBar = _menubar;
for (button in builder._buttons) {
if (button != target) {
button.selected = false;
Expand Down

0 comments on commit b44e521

Please sign in to comment.