aboutsummaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/controls/TextControlService.hpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/ui/controls/TextControlService.hpp b/src/ui/controls/TextControlService.hpp
index 1108a3b2..41959f9d 100644
--- a/src/ui/controls/TextControlService.hpp
+++ b/src/ui/controls/TextControlService.hpp
@@ -87,6 +87,29 @@ class TextControlService : public Object {
return this->control_->GetScrollRenderObject();
}
+ gsl::index GetCaretPosition() {
+ return this->GetTextRenderObject()->GetCaretPosition();
+ }
+
+ void SetCaretPosition(gsl::index position, bool clear_selection = true) {
+ this->GetTextRenderObject()->SetCaretPosition(position);
+ if (clear_selection) {
+ this->GetTextRenderObject()->SetSelectionRange(std::nullopt);
+ }
+ }
+
+ std::optional<TextRange> GetSelection() {
+ return this->GetTextRenderObject()->GetSelectionRange();
+ }
+
+ void SetSelection(std::optional<TextRange> selection,
+ bool set_caret_to_end = true) {
+ this->GetTextRenderObject()->SetSelectionRange(selection);
+ if (selection && set_caret_to_end) {
+ this->GetTextRenderObject()->SetCaretPosition(selection->GetEnd());
+ }
+ }
+
private:
void AbortSelection() {
if (this->select_down_button_.has_value()) {