Trying to fix the more button some more

This commit is contained in:
Lars Brubaker 2021-01-06 11:55:34 -08:00
parent aec5aaebc8
commit 81e3cee25f
3 changed files with 24 additions and 10 deletions

View file

@ -36,12 +36,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
public class PopupButton : GuiWidget, IIgnoredPopupChild, IMenuCreator public class PopupButton : GuiWidget, IIgnoredPopupChild, IMenuCreator
{ {
protected GuiWidget buttonView; protected GuiWidget buttonView;
protected bool menuVisible = false;
private bool menuVisibileAtMouseDown = false; private bool menuVisibileAtMouseDown = false;
private PopupWidget popupWidget; private PopupWidget popupWidget;
private bool overridePopupHAnchor = false; private bool overridePopupHAnchor = false;
private bool overridePopupVAnchor = false; private bool overridePopupVAnchor = false;
public bool MenuVisible { get; private set; } = false;
public PopupButton() public PopupButton()
{ {
} }
@ -66,7 +67,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
public override Color BackgroundColor public override Color BackgroundColor
{ {
get => menuVisible ? this.OpenColor : base.BackgroundColor; get => MenuVisible ? this.OpenColor : base.BackgroundColor;
set => base.BackgroundColor = value; set => base.BackgroundColor = value;
} }
@ -74,7 +75,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
public Color HoverColor { get; set; } = new Color(0, 0, 0, 40); 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; public bool MakeScrollable { get; set; } = true;
@ -121,6 +122,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
this.ShowPopup(); this.ShowPopup();
} }
menuVisibileAtMouseDown = false;
base.OnClick(mouseEvent); base.OnClick(mouseEvent);
} }
@ -133,7 +135,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
public override void OnMouseDown(MouseEventArgs mouseEvent) public override void OnMouseDown(MouseEventArgs mouseEvent)
{ {
// Store the menu state at the time of mousedown // Store the menu state at the time of mousedown
menuVisibileAtMouseDown = menuVisible; menuVisibileAtMouseDown = MenuVisible;
base.OnMouseDown(mouseEvent); base.OnMouseDown(mouseEvent);
} }
@ -144,7 +146,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
PopupLayoutEngine = new PopupLayoutEngine(this.PopupContent, this, this.PopDirection, 0, this.AlignToRightEdge); PopupLayoutEngine = new PopupLayoutEngine(this.PopupContent, this, this.PopDirection, 0, this.AlignToRightEdge);
} }
menuVisible = true; MenuVisible = true;
this.PopupContent?.ClearRemovedFlag(); this.PopupContent?.ClearRemovedFlag();
@ -156,7 +158,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
if (this.PopupContent == null if (this.PopupContent == null
|| this.PopupContent.Children.Count <= 0) || this.PopupContent.Children.Count <= 0)
{ {
menuVisible = false; MenuVisible = false;
return; return;
} }
@ -170,7 +172,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
popupWidget.Closed += (s, e) => popupWidget.Closed += (s, e) =>
{ {
menuVisible = false; MenuVisible = false;
popupWidget = null; popupWidget = null;
this.PopupWindowClosed?.Invoke(this, null); this.PopupWindowClosed?.Invoke(this, null);

View file

@ -161,14 +161,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{ {
get get
{ {
if (!menuVisible if (!MenuVisible
&& this.MouseCaptured && this.MouseCaptured
&& mouseInBounds && mouseInBounds
&& this.Enabled) && this.Enabled)
{ {
return this.MouseDownColor; return this.MouseDownColor;
} }
else if (!menuVisible else if (!MenuVisible
&& mouseInBounds && mouseInBounds
&& this.Enabled) && this.Enabled)
{ {

View file

@ -322,9 +322,21 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
ToolTipText = "Open Settings View Options".Localize() 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) => button.Click += (s, e) =>
{ {
this.TabBar.RightAnchorItem.InvokeClick(); if (!menuWasOpenOnMoreDown)
{
this.TabBar.RightAnchorItem.InvokeClick();
}
}; };
button.RoundRadius = button.Height / 2; button.RoundRadius = button.Height / 2;