From 81e3cee25f99020404dd0925ebb73ea2883366c2 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 6 Jan 2021 11:55:34 -0800 Subject: [PATCH] Trying to fix the more button some more --- .../PartPreviewWindow/PopupButton.cs | 16 +++++++++------- .../PartPreviewWindow/PopupMenuButton.cs | 4 ++-- .../SlicerConfiguration/SliceSettingsWidget.cs | 14 +++++++++++++- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/MatterControlLib/PartPreviewWindow/PopupButton.cs b/MatterControlLib/PartPreviewWindow/PopupButton.cs index fe3268e12..77b2ca3ef 100644 --- a/MatterControlLib/PartPreviewWindow/PopupButton.cs +++ b/MatterControlLib/PartPreviewWindow/PopupButton.cs @@ -36,12 +36,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public class PopupButton : GuiWidget, IIgnoredPopupChild, IMenuCreator { protected GuiWidget buttonView; - protected bool menuVisible = false; private bool menuVisibileAtMouseDown = false; private PopupWidget popupWidget; private bool overridePopupHAnchor = false; private bool overridePopupVAnchor = false; + public bool MenuVisible { get; private set; } = false; + public PopupButton() { } @@ -66,7 +67,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public override Color BackgroundColor { - get => menuVisible ? this.OpenColor : base.BackgroundColor; + get => MenuVisible ? this.OpenColor : base.BackgroundColor; set => base.BackgroundColor = value; } @@ -74,7 +75,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public Color HoverColor { get; set; } = new Color(0, 0, 0, 40); - public bool KeepMenuOpen => menuVisible || this.AlwaysKeepOpen; + public bool KeepMenuOpen => MenuVisible || this.AlwaysKeepOpen; public bool MakeScrollable { get; set; } = true; @@ -121,6 +122,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow this.ShowPopup(); } + menuVisibileAtMouseDown = false; base.OnClick(mouseEvent); } @@ -133,7 +135,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public override void OnMouseDown(MouseEventArgs mouseEvent) { // Store the menu state at the time of mousedown - menuVisibileAtMouseDown = menuVisible; + menuVisibileAtMouseDown = MenuVisible; base.OnMouseDown(mouseEvent); } @@ -144,7 +146,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow PopupLayoutEngine = new PopupLayoutEngine(this.PopupContent, this, this.PopDirection, 0, this.AlignToRightEdge); } - menuVisible = true; + MenuVisible = true; this.PopupContent?.ClearRemovedFlag(); @@ -156,7 +158,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (this.PopupContent == null || this.PopupContent.Children.Count <= 0) { - menuVisible = false; + MenuVisible = false; return; } @@ -170,7 +172,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow popupWidget.Closed += (s, e) => { - menuVisible = false; + MenuVisible = false; popupWidget = null; this.PopupWindowClosed?.Invoke(this, null); diff --git a/MatterControlLib/PartPreviewWindow/PopupMenuButton.cs b/MatterControlLib/PartPreviewWindow/PopupMenuButton.cs index f94da2431..c2fa8d0d8 100644 --- a/MatterControlLib/PartPreviewWindow/PopupMenuButton.cs +++ b/MatterControlLib/PartPreviewWindow/PopupMenuButton.cs @@ -161,14 +161,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { get { - if (!menuVisible + if (!MenuVisible && this.MouseCaptured && mouseInBounds && this.Enabled) { return this.MouseDownColor; } - else if (!menuVisible + else if (!MenuVisible && mouseInBounds && this.Enabled) { diff --git a/MatterControlLib/SlicerConfiguration/SliceSettingsWidget.cs b/MatterControlLib/SlicerConfiguration/SliceSettingsWidget.cs index 7dc883f93..05e21c170 100644 --- a/MatterControlLib/SlicerConfiguration/SliceSettingsWidget.cs +++ b/MatterControlLib/SlicerConfiguration/SliceSettingsWidget.cs @@ -322,9 +322,21 @@ namespace MatterHackers.MatterControl.SlicerConfiguration ToolTipText = "Open Settings View Options".Localize() }; + bool menuWasOpenOnMoreDown = false; + button.MouseDown += (s, e) => + { + if (this.TabBar.RightAnchorItem is OverflowBar.OverflowMenuButton menuButton) + { + menuWasOpenOnMoreDown = menuButton.MenuVisible; + } + }; + button.Click += (s, e) => { - this.TabBar.RightAnchorItem.InvokeClick(); + if (!menuWasOpenOnMoreDown) + { + this.TabBar.RightAnchorItem.InvokeClick(); + } }; button.RoundRadius = button.Height / 2;