Browse Source

protect against copy and cut.

pull/1544/head
Dan Walmsley 8 years ago
parent
commit
d1200e1e47
  1. 18
      src/Avalonia.Controls/TextBox.cs

18
src/Avalonia.Controls/TextBox.cs

@ -126,7 +126,7 @@ namespace Avalonia.Controls
this.GetObservable(TextProperty).Subscribe(text =>
{
if (PasswordChar != default(char))
if (IsPasswordBox)
{
DisplayText = new string(PasswordChar, text.Length);
}
@ -345,7 +345,7 @@ namespace Avalonia.Controls
private async void Copy()
{
await ((IClipboard)AvaloniaLocator.Current.GetService(typeof(IClipboard)))
.SetTextAsync(GetSelection());
.SetTextAsync(GetSelection());
}
private async void Paste()
@ -379,7 +379,10 @@ namespace Avalonia.Controls
case Key.C:
if (modifiers == InputModifiers.Control)
{
Copy();
if (!IsPasswordBox)
{
Copy();
}
handled = true;
}
break;
@ -387,8 +390,11 @@ namespace Avalonia.Controls
case Key.X:
if (modifiers == InputModifiers.Control)
{
Copy();
DeleteSelection();
if (!IsPasswordBox)
{
Copy();
DeleteSelection();
}
handled = true;
}
break;
@ -886,6 +892,8 @@ namespace Avalonia.Controls
SelectionEnd = CaretIndex;
}
private bool IsPasswordBox => PasswordChar != default(char);
UndoRedoState UndoRedoHelper<UndoRedoState>.IUndoRedoHost.UndoRedoState
{
get { return new UndoRedoState(Text, CaretIndex); }

Loading…
Cancel
Save