aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Frontend/GUI/TextInput.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ShiftOS.Frontend/GUI/TextInput.cs')
-rw-r--r--ShiftOS.Frontend/GUI/TextInput.cs42
1 files changed, 42 insertions, 0 deletions
diff --git a/ShiftOS.Frontend/GUI/TextInput.cs b/ShiftOS.Frontend/GUI/TextInput.cs
index e59e927..c4e5260 100644
--- a/ShiftOS.Frontend/GUI/TextInput.cs
+++ b/ShiftOS.Frontend/GUI/TextInput.cs
@@ -17,6 +17,48 @@ namespace ShiftOS.Frontend.GUI
private int _index = 0;
private Font _font = new Font("Tahoma", 9f);
+ public int Index
+ {
+ get
+ {
+ return _index;
+ }
+ set
+ {
+ if (_index == value)
+ return;
+ if(_text.Length == 0)
+ {
+ _index = 0;
+ return;
+ }
+ _index = MathHelper.Clamp(value, 0, _text.Length - 1);
+ if (_text[_index] == '\n')
+ _index++;
+ Invalidate();
+ }
+ }
+
+ public string Text
+ {
+ get
+ {
+ return _text;
+ }
+ set
+ {
+ if (_text == value)
+ return;
+
+ _text = value;
+ if(_index >= _text.Length)
+ {
+ _index = _text.Length - 1;
+ }
+ Invalidate();
+ }
+ }
+
protected override void OnKeyEvent(KeyEvent e)
{
if(e.Key == Microsoft.Xna.Framework.Input.Keys.Left)