aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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: