From 01683f1fcb8a593af66b0a882db7b3a2beba9fa0 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 5 Aug 2017 12:23:25 -0400 Subject: [PATCH] Fix bug with backspace in TextInput --- ShiftOS.Frontend/GUI/TextInput.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ShiftOS.Frontend/GUI/TextInput.cs b/ShiftOS.Frontend/GUI/TextInput.cs index 381541b..36e21b1 100644 --- a/ShiftOS.Frontend/GUI/TextInput.cs +++ b/ShiftOS.Frontend/GUI/TextInput.cs @@ -78,14 +78,6 @@ namespace ShiftOS.Frontend.GUI _index--; } - if(e.Key == Microsoft.Xna.Framework.Input.Keys.Back) - { - if(_index > 0) - { - _text = _text.Remove(_index - 1, 1); - _index--; - } - } if(e.Key == Microsoft.Xna.Framework.Input.Keys.Delete) { if(_index < _text.Length - 1) @@ -97,8 +89,19 @@ namespace ShiftOS.Frontend.GUI if (_index < _text.Length) _index++; if (e.KeyChar != '\0') { - _text = _text.Insert(_index, e.KeyChar.ToString()); - _index++; + if (e.KeyChar == '\b') + { + if (_index > 0) + { + _text = _text.Remove(_index - 1, 1); + _index--; + } + } + else + { + _text = _text.Insert(_index, e.KeyChar.ToString()); + _index++; + } } caretMS = 0; CalculateVisibleText();