Simplify rules and rename to clarify behavior of SetInterval hook
- Issue MatterHackers/MCCentral#3004 Redundancy seems unnecessary
This commit is contained in:
parent
048caeffab
commit
cff26ed09a
1 changed files with 14 additions and 20 deletions
|
|
@ -44,6 +44,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
base.Visible = false;
|
||||
|
||||
double pointSize = 12;
|
||||
|
||||
numberDisplay = new TextWidget(defaultSizeString, 0, 0, pointSize, justification: justification)
|
||||
{
|
||||
Visible = false,
|
||||
|
|
@ -52,6 +53,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
Text = "0",
|
||||
};
|
||||
AddChild(numberDisplay);
|
||||
|
||||
numberEdit = new NumberEdit(0, 50, 50, pointSize, pixelWidth: numberDisplay.Width, allowNegatives: true, allowDecimals: true)
|
||||
{
|
||||
Visible = false,
|
||||
|
|
@ -79,7 +81,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
VAnchor = VAnchor.Fit;
|
||||
HAnchor = HAnchor.Fit;
|
||||
|
||||
UiThread.SetInterval(CheckControlsVisibility, .1, () => !HasBeenClosed);
|
||||
UiThread.SetInterval(HideIfApplicable, .1, () => !HasBeenClosed);
|
||||
}
|
||||
|
||||
public Color TextColor { get; set; } = Color.Black;
|
||||
|
|
@ -181,29 +183,21 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
base.OnMouseDown(mouseEvent);
|
||||
}
|
||||
|
||||
private void CheckControlsVisibility()
|
||||
private void HideIfApplicable()
|
||||
{
|
||||
if (!this.Editing)
|
||||
if (this.Visible)
|
||||
{
|
||||
if (timeSinceMouseUp.IsRunning)
|
||||
if (!this.Editing
|
||||
&& timeSinceMouseUp.IsRunning
|
||||
&& timeSinceMouseUp.ElapsedMilliseconds > SecondsToShowNumberEdit * 1000)
|
||||
{
|
||||
if (timeSinceMouseUp.ElapsedMilliseconds > SecondsToShowNumberEdit * 1000)
|
||||
{
|
||||
if (this.Editing)
|
||||
{
|
||||
}
|
||||
else if (timeSinceMouseUp.IsRunning)
|
||||
{
|
||||
Visible = false;
|
||||
}
|
||||
}
|
||||
Visible = false;
|
||||
}
|
||||
else if (this.ForceHide?.Invoke() == true)
|
||||
{
|
||||
// Hide if custom ForceHide implementations say to do so
|
||||
this.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Visible && ForceHide?.Invoke() == true)
|
||||
{
|
||||
// If the user is hovering on a different control
|
||||
Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue