Textbox Pointer Fix

I made some changes to hopefully keep the pointer in the right location.
This commit is contained in:
JacobTech 2024-04-13 13:30:28 -04:00
parent 532d212494
commit 47469e0f1a

View File

@ -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;