From fd15b6bc9e07135472b5e2ee12bc8fba7d7f5567 Mon Sep 17 00:00:00 2001 From: nil4 Date: Fri, 15 Mar 2024 02:56:31 +0100 Subject: [PATCH] Double-clicking in a `TextBox` with `PasswordChar` set selects all text when the password is not revealed. (#14973) If the password text is revealed, the pre-existing word-based selection model remains (the closest word to the pointer position is selected.) Related to https://github.com/AvaloniaUI/Avalonia/issues/14956 --- src/Avalonia.Controls/TextBox.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index 91538df3e3..c36b17b505 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -1578,6 +1578,13 @@ namespace Avalonia.Controls break; case 2: + if (IsPasswordBox && !RevealPassword) + { + // double-clicking in a cloaked single-line password box selects all text + // see https://github.com/AvaloniaUI/Avalonia/issues/14956 + goto case 3; + } + if (!StringUtils.IsStartOfWord(text, caretIndex)) { selectionStart = StringUtils.PreviousWord(text, caretIndex);