/// <summary> /// Handles updating the text of the TextBox /// </summary> protected virtual void handleTextUpdate() { Keys[] pressedKeys = InputManager.getInstance().getNewKeys(); if (pressedKeys != null && pressedKeys.Length > 0) { string newText = null; KeyValuePair <Keys, string> defaultKVP = default(KeyValuePair <Keys, string>); KeyValuePair <Keys, string> result = defaultKVP; foreach (Keys key in pressedKeys) { if (Keys.Back == key) { if (this.text.Length > 0) { this.text = this.text.Substring(0, this.text.Length - 1); } } else if (this.text.Length < MAX_LENGTH) { if (Keys.Space == key) { this.text += " "; } else if (VALID_KEYS.Contains(key)) { // do we have a translation? newText = KeyLists.translate(key); this.text += newText; } } } this.text2D.WrittenText = this.text; } }
/// <summary> /// handles the text update /// </summary> protected override void handleTextUpdate() { Keys[] pressedKeys = InputManager.getInstance().getNewKeys(); if (pressedKeys != null && pressedKeys.Length > 0) { string newText = null; foreach (Keys key in pressedKeys) { if (Keys.Escape == key) { base.text = this.previousText; base.HasFocus = false; break; } else if (base.text.Length < base.MAX_LENGTH) { if (Keys.Enter != key) { // do we have a translation? newText = KeyLists.translate(key); this.BoundTo = key; this.previousText = newText; base.text += newText; base.HasFocus = false; break; } } } base.text2D.WrittenText = base.text; } }