aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/TextControlService.hpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-10-28 17:51:41 +0800
committercrupest <crupest@outlook.com>2020-10-28 17:51:41 +0800
commit4e0a5338f15a247c33df863c4c619ffdb0a98aae (patch)
tree491aac2d3612b4343143ea157fb33611d5c3d5e8 /src/ui/controls/TextControlService.hpp
parent864b031211322dc276b220ec0a6e11483503a0e9 (diff)
downloadcru-4e0a5338f15a247c33df863c4c619ffdb0a98aae.tar.gz
cru-4e0a5338f15a247c33df863c4c619ffdb0a98aae.tar.bz2
cru-4e0a5338f15a247c33df863c4c619ffdb0a98aae.zip
...
Diffstat (limited to 'src/ui/controls/TextControlService.hpp')
-rw-r--r--src/ui/controls/TextControlService.hpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/ui/controls/TextControlService.hpp b/src/ui/controls/TextControlService.hpp
index 04807c30..376f9177 100644
--- a/src/ui/controls/TextControlService.hpp
+++ b/src/ui/controls/TextControlService.hpp
@@ -206,16 +206,12 @@ class TextControlService : public Object {
SetSelection(GetSelection().GetStart() + text.size());
}
- void ScrollToCaret(bool next_tick = true) {
- if (next_tick) {
- scroll_to_caret_timer_canceler_.Reset(
- GetUiApplication()->GetInstance()->SetImmediate(
- [this]() { this->ScrollToCaret(false); }));
- } else {
+ void ScrollToCaret() {
+ this->control_->GetUiHost()->RunAfterLayoutStable([this]() {
const auto caret_rect = this->GetTextRenderObject()->GetCaretRect();
this->GetScrollRenderObject()->ScrollToContain(caret_rect,
Thickness{5.f});
- }
+ });
}
private:
@@ -453,8 +449,6 @@ class TextControlService : public Object {
ShortcutHub shortcut_hub_;
- platform::native::TimerAutoCanceler scroll_to_caret_timer_canceler_;
-
// nullopt means not selecting
std::optional<MouseButton> select_down_button_;