Added a change cursor boolean to TextBoxBase and made it so the cursor changes to default when hovering over the cancel button.
This commit is contained in:
@@ -49,6 +49,12 @@ namespace FlaxEditor.GUI.Input
|
||||
ClearSearchButton.LocalY += 2;
|
||||
ClearSearchButton.LocalX -= 2;
|
||||
ClearSearchButton.Clicked += Clear;
|
||||
ClearSearchButton.HoverBegin += () =>
|
||||
{
|
||||
_changeCursor = false;
|
||||
Cursor = CursorType.Default;
|
||||
};
|
||||
ClearSearchButton.HoverEnd += () => _changeCursor = true;
|
||||
|
||||
TextChanged += () => ClearSearchButton.Visible = !string.IsNullOrEmpty(Text);
|
||||
}
|
||||
|
||||
@@ -114,6 +114,11 @@ namespace FlaxEngine.GUI
|
||||
/// </summary>
|
||||
protected float _animateTime;
|
||||
|
||||
/// <summary>
|
||||
/// If the cursor should change to an IBeam
|
||||
/// </summary>
|
||||
protected bool _changeCursor = true;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when text gets changed
|
||||
/// </summary>
|
||||
@@ -1131,7 +1136,7 @@ namespace FlaxEngine.GUI
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseEnter(Float2 location)
|
||||
{
|
||||
if (_isEditing)
|
||||
if (_isEditing && _changeCursor)
|
||||
Cursor = CursorType.IBeam;
|
||||
|
||||
base.OnMouseEnter(location);
|
||||
@@ -1159,8 +1164,8 @@ namespace FlaxEngine.GUI
|
||||
// Modify selection end
|
||||
SetSelection(_selectionStart, currentIndex);
|
||||
}
|
||||
|
||||
if (Cursor == CursorType.Default && _isEditing)
|
||||
|
||||
if (Cursor == CursorType.Default && _isEditing && _changeCursor)
|
||||
Cursor = CursorType.IBeam;
|
||||
}
|
||||
|
||||
@@ -1200,6 +1205,8 @@ namespace FlaxEngine.GUI
|
||||
if (button == MouseButton.Left && !IsFocused)
|
||||
{
|
||||
Focus();
|
||||
if (_changeCursor)
|
||||
Cursor = CursorType.IBeam;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user