Add value auto-select when focusing or clicking on input field in Editor
This commit is contained in:
@@ -55,6 +55,7 @@ namespace FlaxEditor.GUI.Input
|
||||
protected string _startEditText;
|
||||
|
||||
private Vector2 _startSlideLocation;
|
||||
private double _clickStartTime = -1;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when value gets changed.
|
||||
@@ -196,6 +197,14 @@ namespace FlaxEditor.GUI.Input
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnGotFocus()
|
||||
{
|
||||
base.OnGotFocus();
|
||||
|
||||
SelectAll();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnLostFocus()
|
||||
{
|
||||
@@ -231,6 +240,9 @@ namespace FlaxEditor.GUI.Input
|
||||
return true;
|
||||
}
|
||||
|
||||
if (button == MouseButton.Left && !IsFocused)
|
||||
_clickStartTime = Platform.TimeSeconds;
|
||||
|
||||
return base.OnMouseDown(location, button);
|
||||
}
|
||||
|
||||
@@ -242,11 +254,10 @@ namespace FlaxEditor.GUI.Input
|
||||
// Update sliding
|
||||
Vector2 slideLocation = location + Root.TrackingMouseOffset;
|
||||
ApplySliding(Mathf.RoundToInt(slideLocation.X - _startSlideLocation.X) * _slideSpeed);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
base.OnMouseMove(location);
|
||||
}
|
||||
|
||||
base.OnMouseMove(location);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -259,6 +270,14 @@ namespace FlaxEditor.GUI.Input
|
||||
return true;
|
||||
}
|
||||
|
||||
if (button == MouseButton.Left && _clickStartTime > 0 && (Platform.TimeSeconds - _clickStartTime) < 0.2f)
|
||||
{
|
||||
_clickStartTime = -1;
|
||||
OnSelectingEnd();
|
||||
SelectAll();
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnMouseUp(location, button);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user