From 4eae631af2bda33bd36b1cbcdca367fef54e12a8 Mon Sep 17 00:00:00 2001 From: Dylan Wilson Date: Tue, 23 May 2017 20:42:09 +1000 Subject: [PATCH] fixed some bugs in gui text box --- Source/MonoGame.Extended.Gui/Controls/GuiTextBox.cs | 8 +++++++- Source/MonoGame.Extended.Gui/GuiScreen.cs | 1 - Source/Tests/Sandbox/Game1.cs | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Source/MonoGame.Extended.Gui/Controls/GuiTextBox.cs b/Source/MonoGame.Extended.Gui/Controls/GuiTextBox.cs index 078e83ee..8c4edc2c 100644 --- a/Source/MonoGame.Extended.Gui/Controls/GuiTextBox.cs +++ b/Source/MonoGame.Extended.Gui/Controls/GuiTextBox.cs @@ -80,11 +80,17 @@ namespace MonoGame.Extended.Gui.Controls if (SelectionStart < Text.Length) SelectionStart++; break; + case Keys.Home: + SelectionStart = 0; + break; + case Keys.End: + SelectionStart = Text.Length; + break; default: if (args.Character != null) { + Text = Text.Insert(SelectionStart, args.Character.ToString()); SelectionStart++; - Text += args.Character; } break; } diff --git a/Source/MonoGame.Extended.Gui/GuiScreen.cs b/Source/MonoGame.Extended.Gui/GuiScreen.cs index 316149c0..54237606 100644 --- a/Source/MonoGame.Extended.Gui/GuiScreen.cs +++ b/Source/MonoGame.Extended.Gui/GuiScreen.cs @@ -3,7 +3,6 @@ using System.IO; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; -using Microsoft.Xna.Framework.Graphics; using MonoGame.Extended.Gui.Controls; using MonoGame.Extended.Gui.Serialization; using Newtonsoft.Json; diff --git a/Source/Tests/Sandbox/Game1.cs b/Source/Tests/Sandbox/Game1.cs index 0901bd6b..048d4690 100644 --- a/Source/Tests/Sandbox/Game1.cs +++ b/Source/Tests/Sandbox/Game1.cs @@ -52,7 +52,7 @@ namespace Sandbox { Controls = { - //new GuiLabel { Text = "Hello World" } + new GuiTextBox { Text = "Hello World" } } } };