Browse Source

Added AcceptsReturn and AcceptsTab to TextBox.

pull/10/head
Steven Kirk 12 years ago
parent
commit
dc6a6feb49
  1. 34
      Perspex.Controls/TextBox.cs

34
Perspex.Controls/TextBox.cs

@ -16,6 +16,12 @@ namespace Perspex.Controls
public class TextBox : TemplatedControl
{
public static readonly PerspexProperty<bool> AcceptsReturnProperty =
PerspexProperty.Register<TextBox, bool>("AcceptsReturn");
public static readonly PerspexProperty<bool> AcceptsTabProperty =
PerspexProperty.Register<TextBox, bool>("AcceptsTab");
public static readonly PerspexProperty<string> TextProperty =
TextBlock.TextProperty.AddOwner<TextBox>();
@ -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))
{

Loading…
Cancel
Save