Browse Source

Merge pull request #3572 from Symbai/textboxSelect

Expose TextBox.SelectAll
pull/3575/head
Dariusz Komosiński 7 years ago
committed by GitHub
parent
commit
eaa8c68c3a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/Avalonia.Controls/TextBox.cs

11
src/Avalonia.Controls/TextBox.cs

@ -316,8 +316,7 @@ namespace Avalonia.Controls
!AcceptsReturn && !AcceptsReturn &&
Text?.Length > 0) Text?.Length > 0)
{ {
SelectionStart = 0; SelectAll();
SelectionEnd = Text.Length;
} }
else else
{ {
@ -673,8 +672,7 @@ namespace Avalonia.Controls
SelectionEnd = StringUtils.NextWord(text, index); SelectionEnd = StringUtils.NextWord(text, index);
break; break;
case 3: case 3:
SelectionStart = 0; SelectAll();
SelectionEnd = text.Length;
break; break;
} }
} }
@ -896,7 +894,10 @@ namespace Avalonia.Controls
CaretIndex = caretIndex; CaretIndex = caretIndex;
} }
private void SelectAll() /// <summary>
/// Select all text in the TextBox
/// </summary>
public void SelectAll()
{ {
SelectionStart = 0; SelectionStart = 0;
SelectionEnd = Text?.Length ?? 0; SelectionEnd = Text?.Length ?? 0;

Loading…
Cancel
Save