diff --git a/Perspex.Controls/TextBox.cs b/Perspex.Controls/TextBox.cs index 710617a708..792bf8464a 100644 --- a/Perspex.Controls/TextBox.cs +++ b/Perspex.Controls/TextBox.cs @@ -16,6 +16,12 @@ namespace Perspex.Controls public class TextBox : TemplatedControl { + public static readonly PerspexProperty AcceptsReturnProperty = + PerspexProperty.Register("AcceptsReturn"); + + public static readonly PerspexProperty AcceptsTabProperty = + PerspexProperty.Register("AcceptsTab"); + public static readonly PerspexProperty TextProperty = TextBlock.TextProperty.AddOwner(); @@ -36,6 +42,18 @@ namespace Perspex.Controls this.PointerPressed += this.OnPointerPressed; } + public bool AcceptsReturn + { + get { return this.GetValue(AcceptsReturnProperty); } + set { this.SetValue(AcceptsReturnProperty, value); } + } + + public bool AcceptsTab + { + get { return this.GetValue(AcceptsTabProperty); } + set { this.SetValue(AcceptsTabProperty, value); } + } + public int CaretIndex { get @@ -111,6 +129,22 @@ namespace Perspex.Controls break; + case Key.Enter: + if (this.AcceptsReturn) + { + goto default; + } + + break; + + case Key.Tab: + if (this.AcceptsTab) + { + goto default; + } + + break; + default: if (!string.IsNullOrEmpty(e.Text)) {