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