From eca1e1334eceeb866a36c95d95049118efcc76b0 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 11 Dec 2014 14:29:21 +0100 Subject: [PATCH] Don't remove selection when nothing entered. --- Perspex.Controls/TextBox.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Perspex.Controls/TextBox.cs b/Perspex.Controls/TextBox.cs index 18ec2c7b3a..e6e7184cfc 100644 --- a/Perspex.Controls/TextBox.cs +++ b/Perspex.Controls/TextBox.cs @@ -238,6 +238,7 @@ namespace Perspex.Controls string text = this.Text ?? string.Empty; int caretIndex = this.CaretIndex; bool movement = false; + bool textEntered = false; var modifiers = e.Device.Modifiers; switch (e.Key) @@ -313,6 +314,7 @@ namespace Perspex.Controls text = this.Text; this.Text = text.Substring(0, caretIndex) + e.Text + text.Substring(caretIndex); ++this.CaretIndex; + textEntered = true; } break; @@ -322,7 +324,7 @@ namespace Perspex.Controls { this.SelectionEnd = this.CaretIndex; } - else + else if (textEntered) { this.SelectionStart = this.SelectionEnd = this.CaretIndex; }