aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Frontend/GUI
diff options
context:
space:
mode:
Diffstat (limited to 'ShiftOS.Frontend/GUI')
-rw-r--r--ShiftOS.Frontend/GUI/TextControl.cs1
-rw-r--r--ShiftOS.Frontend/GUI/TextInput.cs42
2 files changed, 42 insertions, 1 deletions
diff --git a/ShiftOS.Frontend/GUI/TextControl.cs b/ShiftOS.Frontend/GUI/TextControl.cs
index 9bf240f..9bc70e8 100644
--- a/ShiftOS.Frontend/GUI/TextControl.cs
+++ b/ShiftOS.Frontend/GUI/TextControl.cs
@@ -92,7 +92,6 @@ namespace ShiftOS.Frontend.GUI
}
- base.OnPaint(gfx);
gfx.DrawString(_text, _font, new SolidBrush(Engine.SkinEngine.LoadedSkin.ControlTextColor), new RectangleF(loc.X, loc.Y, sMeasure.Width, sMeasure.Height));
}
}
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)