From 11eb08b08fc0b0d146bb691f96dfc13baf882eb8 Mon Sep 17 00:00:00 2001 From: blankie Date: Thu, 5 Jan 2023 20:53:23 +0700 Subject: [PATCH] Add autoscroll --- event_loop.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/event_loop.cpp b/event_loop.cpp index b42ee9e..3b082a0 100644 --- a/event_loop.cpp +++ b/event_loop.cpp @@ -41,11 +41,13 @@ static inline void logs_window(bool* show_logs_window) { ImGui::SetClipboardText(log_entries.c_str()); } - // copied from imgui/imgui_demo.cpp: [SECTION] Example App: Debug Console / ShowExampleAppConsole() - ImGui::Separator(); + // copied from imgui/imgui_demo.cpp: [SECTION] Example App: Debug Console / ShowExampleAppConsole() if (ImGui::BeginChild("ScrollingRegion", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar)) { ImGui::TextUnformatted(log_entries.data(), &log_entries[log_entries.size()]); + if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) { + ImGui::SetScrollHereY(1.0f); + } } ImGui::EndChild(); ImGui::End();