Browse Source
Merge pull request #1189 from JurjenBiewenga/InvalidCharInput
Invalid char input
pull/1293/head
Steven Kirk
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
12 additions and
0 deletions
-
src/Avalonia.Controls/TextBox.cs
|
|
|
@ -97,6 +97,7 @@ namespace Avalonia.Controls |
|
|
|
private UndoRedoHelper<UndoRedoState> _undoRedoHelper; |
|
|
|
private bool _ignoreTextChanges; |
|
|
|
private IEnumerable<Exception> _dataValidationErrors; |
|
|
|
private static readonly string[] invalidCharacters = new String[1]{"\u007f"}; |
|
|
|
|
|
|
|
static TextBox() |
|
|
|
{ |
|
|
|
@ -280,6 +281,7 @@ namespace Avalonia.Controls |
|
|
|
{ |
|
|
|
if (!IsReadOnly) |
|
|
|
{ |
|
|
|
input = RemoveInvalidCharacters(input); |
|
|
|
string text = Text ?? string.Empty; |
|
|
|
int caretIndex = CaretIndex; |
|
|
|
if (!string.IsNullOrEmpty(input)) |
|
|
|
@ -295,6 +297,16 @@ namespace Avalonia.Controls |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public string RemoveInvalidCharacters(string text) |
|
|
|
{ |
|
|
|
for (var i = 0; i < invalidCharacters.Length; i++) |
|
|
|
{ |
|
|
|
text = text.Replace(invalidCharacters[i], string.Empty); |
|
|
|
} |
|
|
|
|
|
|
|
return text; |
|
|
|
} |
|
|
|
|
|
|
|
private async void Copy() |
|
|
|
{ |
|
|
|
await ((IClipboard)AvaloniaLocator.Current.GetService(typeof(IClipboard))) |
|
|
|
|