aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-09-11 10:13:53 +0800
committercrupest <crupest@outlook.com>2020-09-11 10:13:53 +0800
commit65ca046989cd641da65b754bfa1c99f5e54b219a (patch)
treee87a0272bf62d9f1293d6ed2715ceaf8c5412e56 /src/ui/controls
parent220e397e1e7276853212ffa97403c1440ed55492 (diff)
downloadcru-65ca046989cd641da65b754bfa1c99f5e54b219a.tar.gz
cru-65ca046989cd641da65b754bfa1c99f5e54b219a.tar.bz2
cru-65ca046989cd641da65b754bfa1c99f5e54b219a.zip
...
Diffstat (limited to 'src/ui/controls')
-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()) {