Fix using TextBoxBase with child controls

(cherry picked from commit 2b41c8d24f)
This commit is contained in:
Wojtek Figat
2021-04-26 15:15:17 +02:00
parent b73ff9aaf6
commit 35f06bbf6e

View File

@@ -279,10 +279,11 @@ namespace FlaxEngine.GUI
}
/// <summary>
/// Sets the text.
/// Sets the text (forced, even if user is editing it).
/// </summary>
/// <param name="value">The value.</param>
protected void SetText(string value)
[NoAnimate]
public void SetText(string value)
{
// Prevent from null problems
if (value == null)
@@ -314,6 +315,18 @@ namespace FlaxEngine.GUI
}
}
/// <summary>
/// Sets the text as it was entered by user (focus, change value, defocus).
/// </summary>
/// <param name="value">The value.</param>
[NoAnimate]
public void SetTextAsUser(string value)
{
Focus();
SetText(value);
Defocus();
}
/// <summary>
/// Gets length of the text
/// </summary>
@@ -1000,7 +1013,8 @@ namespace FlaxEngine.GUI
/// <inheritdoc />
public override void OnMouseMove(Vector2 location)
{
// Check if user is selecting
base.OnMouseMove(location);
if (_isSelecting)
{
// Find char index at current mouse location
@@ -1014,6 +1028,9 @@ namespace FlaxEngine.GUI
/// <inheritdoc />
public override bool OnMouseDown(Vector2 location, MouseButton button)
{
if (base.OnMouseDown(location, button))
return true;
if (button == MouseButton.Left && _text.Length > 0)
{
Focus();
@@ -1050,6 +1067,9 @@ namespace FlaxEngine.GUI
/// <inheritdoc />
public override bool OnMouseUp(Vector2 location, MouseButton button)
{
if (base.OnMouseUp(location, button))
return true;
if (button == MouseButton.Left)
{
OnSelectingEnd();
@@ -1079,6 +1099,8 @@ namespace FlaxEngine.GUI
/// <inheritdoc />
public override bool OnCharInput(char c)
{
if (base.OnCharInput(c))
return true;
Insert(c);
return true;
}