diff options
author | crupest <crupest@outlook.com> | 2021-11-17 19:41:39 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-11-17 19:41:39 +0800 |
commit | 0f3e84f0ef4c62d20e5cb4d9e5677ec39afb894d (patch) | |
tree | d1f4c0686fd12f82b8af5b3ca015b5d995d773ff /src/ui/controls | |
parent | 7be210036e363f2105ace761451448507d4b06d8 (diff) | |
download | cru-0f3e84f0ef4c62d20e5cb4d9e5677ec39afb894d.tar.gz cru-0f3e84f0ef4c62d20e5cb4d9e5677ec39afb894d.tar.bz2 cru-0f3e84f0ef4c62d20e5cb4d9e5677ec39afb894d.zip |
...
Diffstat (limited to 'src/ui/controls')
-rw-r--r-- | src/ui/controls/TextHostControlService.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
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; |