From ade0450c0e232b1c917e96c1b6472a5122b4bba8 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 1 Feb 2023 09:12:10 -0600 Subject: [PATCH 1/3] Add cursor to change to Ibeam in text boxes. --- Source/Engine/UI/GUI/Common/TextBoxBase.cs | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Source/Engine/UI/GUI/Common/TextBoxBase.cs b/Source/Engine/UI/GUI/Common/TextBoxBase.cs index 24657b62f..098f81734 100644 --- a/Source/Engine/UI/GUI/Common/TextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/TextBoxBase.cs @@ -1128,6 +1128,23 @@ namespace FlaxEngine.GUI base.OnSubmit(); } + /// + public override void OnMouseEnter(Float2 location) + { + Cursor = CursorType.IBeam; + base.OnMouseEnter(location); + } + + /// + public override void OnMouseLeave() + { + if (Cursor == CursorType.IBeam) + { + Cursor = CursorType.Default; + } + base.OnMouseLeave(); + } + /// public override void OnMouseMove(Float2 location) { @@ -1141,6 +1158,11 @@ namespace FlaxEngine.GUI // Modify selection end SetSelection(_selectionStart, currentIndex); } + + if (Cursor == CursorType.Default) + { + Cursor = CursorType.IBeam; + } } /// @@ -1169,6 +1191,11 @@ namespace FlaxEngine.GUI { SetSelection(hitPos); } + + if (Cursor == CursorType.Default) + { + Cursor = CursorType.IBeam; + } return true; } From b8621262096f368b38702399fc2580c70887b932 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 1 Feb 2023 18:25:40 -0600 Subject: [PATCH 2/3] Changed to only show ibeam when editing --- Source/Engine/UI/GUI/Common/TextBoxBase.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/Engine/UI/GUI/Common/TextBoxBase.cs b/Source/Engine/UI/GUI/Common/TextBoxBase.cs index 098f81734..cfbf425bd 100644 --- a/Source/Engine/UI/GUI/Common/TextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/TextBoxBase.cs @@ -1131,7 +1131,9 @@ namespace FlaxEngine.GUI /// public override void OnMouseEnter(Float2 location) { - Cursor = CursorType.IBeam; + if (_isEditing) + Cursor = CursorType.IBeam; + base.OnMouseEnter(location); } @@ -1159,7 +1161,7 @@ namespace FlaxEngine.GUI SetSelection(_selectionStart, currentIndex); } - if (Cursor == CursorType.Default) + if (Cursor == CursorType.Default && _isEditing) { Cursor = CursorType.IBeam; } From 25928417937324d3b8ff47404aa19b89874f9148 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 1 Feb 2023 18:28:00 -0600 Subject: [PATCH 3/3] Code style cleanup --- Source/Engine/UI/GUI/Common/TextBoxBase.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Source/Engine/UI/GUI/Common/TextBoxBase.cs b/Source/Engine/UI/GUI/Common/TextBoxBase.cs index cfbf425bd..12760c176 100644 --- a/Source/Engine/UI/GUI/Common/TextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/TextBoxBase.cs @@ -1141,9 +1141,8 @@ namespace FlaxEngine.GUI public override void OnMouseLeave() { if (Cursor == CursorType.IBeam) - { Cursor = CursorType.Default; - } + base.OnMouseLeave(); } @@ -1162,9 +1161,7 @@ namespace FlaxEngine.GUI } if (Cursor == CursorType.Default && _isEditing) - { Cursor = CursorType.IBeam; - } } /// @@ -1195,9 +1192,7 @@ namespace FlaxEngine.GUI } if (Cursor == CursorType.Default) - { Cursor = CursorType.IBeam; - } return true; }