From 0f3e84f0ef4c62d20e5cb4d9e5677ec39afb894d Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 17 Nov 2021 19:41:39 +0800 Subject: ... --- src/ui/controls/TextHostControlService.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/ui/controls') diff --git a/src/ui/controls/TextHostControlService.cpp b/src/ui/controls/TextHostControlService.cpp index 42153ffd..edfabb94 100644 --- a/src/ui/controls/TextHostControlService.cpp +++ b/src/ui/controls/TextHostControlService.cpp @@ -318,6 +318,10 @@ void TextHostControlService::SetSelection(TextRange selection, } } +void TextHostControlService::SelectAll() { + this->SetSelection(TextRange{0, this->text_.size()}); +} + void TextHostControlService::ChangeSelectionEnd(Index new_end) { auto selection = GetSelection(); selection.ChangeEnd(new_end); @@ -482,6 +486,16 @@ void TextHostControlService::LoseFocusHandler( void TextHostControlService::SetUpShortcuts() { using platform::gui::KeyCode; using platform::gui::KeyModifiers; + using platform::gui::kKeyModifierCommand; + + shortcut_hub_.RegisterShortcut(u"Select All", + {KeyCode::A, kKeyModifierCommand}, [this] { + if (IsEnabled()) { + this->SelectAll(); + return true; + } + return false; + }); shortcut_hub_.RegisterShortcut(u"Backspace", KeyCode::Backspace, [this] { if (!IsEnabled()) return false; -- cgit v1.2.3