|
|
|
@ -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)) |
|
|
|
{ |
|
|
|
|