private void OpenPopupFor(MenuBarTopButton button) { _popupVBox.RemoveAllChildren(); var menu = button.Menu; ConstructMenu(menu, _popupVBox); var globalPos = button.GlobalPosition; globalPos += new Vector2(0, button.Height); _popup.Open(UIBox2.FromDimensions(globalPos, _popupVBox.Size)); // Set this after running open so that if this is called from MouseEntered, // It won't get set to false by Open() closing the popup to move it. _popupOpen = true; }
private void AddMenu(Menu menu) { var button = new MenuBarTopButton(menu); _menus.Add(menu); _buttons.Add(button); _hBox.AddChild(button); button.OnMouseButtonDown += _ => OpenPopupFor(button); button.OnMouseEntered += _ => { if (_popupOpen) { OpenPopupFor(button); } }; }