From d00ed24d14ba5c729ba083a78e835d3a7e730308 Mon Sep 17 00:00:00 2001 From: Jyrki Vesterinen Date: Mon, 4 Dec 2017 20:53:12 +0200 Subject: [PATCH] Fix #2067: Scrolling position in Lua console is reset constantly The problem is that a line that's too wide to fit into the window invalidates the layout of the entire window, and the window will lay itself out the next time it will be drawn, after the Lua console code has scrolled it to bottom. The easiest fix is to simply defer scrolling to bottom until the window has been drawn (and thus laid out) next time. --- src/gui/dialogs/lua_interpreter.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/dialogs/lua_interpreter.cpp b/src/gui/dialogs/lua_interpreter.cpp index fde1e291bb9..36658e9df66 100644 --- a/src/gui/dialogs/lua_interpreter.cpp +++ b/src/gui/dialogs/lua_interpreter.cpp @@ -80,12 +80,14 @@ REGISTER_DIALOG(lua_interpreter) class lua_interpreter::view { private: scroll_label* msg_label; //the view is extremely simple, it's pretty much just this one widget that gets updated + window* window_; public: - view() : msg_label(nullptr) {} + view() : msg_label(nullptr), window_(nullptr) {} /** Bind the scroll label widget to my pointer, and configure */ void bind(window& window) { + window_ = &window; msg_label = find_widget(&window, "msg", false, true); msg_label->set_use_markup(true); msg_label->set_vertical_scrollbar_mode(scrollbar_container::ALWAYS_VISIBLE); @@ -98,7 +100,10 @@ public: assert(msg_label); msg_label->set_label(str); - msg_label->scroll_vertical_scrollbar(scrollbar_base::END); + window_->set_callback_next_draw([this]() + { + msg_label->scroll_vertical_scrollbar(scrollbar_base::END); + }); } void pg_up()