aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-10-29 00:21:54 +0800
committercrupest <crupest@outlook.com>2020-10-29 00:21:54 +0800
commit6c77f107084908af8d10ded015ccd03663cdc893 (patch)
treee2b1032b372edfcf19a00631fd438c31d0d01f41 /src
parentc5125e9034a5b05700ed41aee30f43476cb2c7f2 (diff)
downloadcru-6c77f107084908af8d10ded015ccd03663cdc893.tar.gz
cru-6c77f107084908af8d10ded015ccd03663cdc893.tar.bz2
cru-6c77f107084908af8d10ded015ccd03663cdc893.zip
...
Diffstat (limited to 'src')
-rw-r--r--src/ui/controls/TextControlService.hpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/ui/controls/TextControlService.hpp b/src/ui/controls/TextControlService.hpp
index 33a6bc36..3c082bad 100644
--- a/src/ui/controls/TextControlService.hpp
+++ b/src/ui/controls/TextControlService.hpp
@@ -223,11 +223,13 @@ class TextControlService : public Object {
}
void ScrollToCaret() {
- this->control_->GetWindowHost()->RunAfterLayoutStable([this]() {
- const auto caret_rect = this->GetTextRenderObject()->GetCaretRect();
- this->GetScrollRenderObject()->ScrollToContain(caret_rect,
- Thickness{5.f});
- });
+ if (const auto scroll_render_object = this->GetScrollRenderObject()) {
+ this->control_->GetWindowHost()->RunAfterLayoutStable(
+ [this, scroll_render_object]() {
+ const auto caret_rect = this->GetTextRenderObject()->GetCaretRect();
+ scroll_render_object->ScrollToContain(caret_rect, Thickness{5.f});
+ });
+ }
}
private: