From 47469e0f1ab00be0f168d266d0b2a8c8c0f2497c Mon Sep 17 00:00:00 2001 From: JacobTech Date: Sat, 13 Apr 2024 13:30:28 -0400 Subject: [PATCH] Textbox Pointer Fix I made some changes to hopefully keep the pointer in the right location. --- Luski/GUI/MainScreen/UI/LuskiControls/TextBox.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Luski/GUI/MainScreen/UI/LuskiControls/TextBox.cs b/Luski/GUI/MainScreen/UI/LuskiControls/TextBox.cs index f4083e3..0fb71c8 100644 --- a/Luski/GUI/MainScreen/UI/LuskiControls/TextBox.cs +++ b/Luski/GUI/MainScreen/UI/LuskiControls/TextBox.cs @@ -236,6 +236,13 @@ public class TextBox : UserControl _label.Location = _label.Location; } } + + if (_label.Text.Length < CursorLocation) + { + CursorLocation = _label.Text.Length; + var xy = _label.GetCharLocation(CursorLocation); + Pointer.Location = new(_label.Location.X + xy.X, _label.Location.Y + xy.Y, Pointer.Location.Z); + } } } public string WatermarkText @@ -283,8 +290,8 @@ public class TextBox : UserControl Size = new(Size.X, Size.Y - (int)_label.Font.PixelHeight); if (OnRemoveLine is not null) OnRemoveLine.Invoke(); } - Text = Text.Remove(CursorLocation - 1, 1); CursorLocation--; + Text = Text.Remove(CursorLocation, 1); var f = _label.GetCharLocation(CursorLocation); Pointer.Location = _label.Location + new Vector3i(f.X, f.Y, 0); Pointer.Visible = true;