From 636ea2666fd836f4090eeff5f1ab9752913e7d71 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 22 Feb 2024 23:22:27 +0300 Subject: [PATCH] textbox ctrl+a --- src/frontend/gui/controls.cpp | 11 +++++++++++ src/frontend/gui/controls.h | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/frontend/gui/controls.cpp b/src/frontend/gui/controls.cpp index 0509d9ee..9b29c6b1 100644 --- a/src/frontend/gui/controls.cpp +++ b/src/frontend/gui/controls.cpp @@ -511,6 +511,17 @@ void TextBox::keyPressed(int key) { paste(util::str2wstr_utf8(text)); } } + // Select/deselect all + if (key == keycode::A) { + if (selectionStart == selectionEnd) { + selectionStart = 0; + selectionEnd = input.length(); + selectionOrigin = 0; + setCaret(selectionEnd); + } else { + resetSelection(); + } + } } } diff --git a/src/frontend/gui/controls.h b/src/frontend/gui/controls.h index 2e78a731..2452992b 100644 --- a/src/frontend/gui/controls.h +++ b/src/frontend/gui/controls.h @@ -148,9 +148,9 @@ namespace gui { virtual glm::vec4 getFocusedColor() const; virtual void setErrorColor(glm::vec4 color); virtual glm::vec4 getErrorColor() const; - /* Get TextBox content text or placeholder if empty */ + /// @brief Get TextBox content text or placeholder if empty virtual std::wstring getText() const; - /* Set TextBox content text */ + /// @brief Set TextBox content text virtual void setText(std::wstring value); virtual std::wstring getPlaceholder() const; virtual void setPlaceholder(const std::wstring&);