Home / Forums / How to handle text clipping and auto-scroll in custom Dear ImGui log consoles?

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Question

How to handle text clipping and auto-scroll in custom Dear ImGui log consoles?

StructMapper
SDK & Class Builder
MEMBER
Rep: 160
Join Date: May 2024
Posts: 26
Thanks: 39
2y ago · May 22, 2024 11:24 AM
#1
I am building an in-game debug console in Dear ImGui. How can I implement smooth auto-scrolling to the bottom when new logs arrive, while allowing the user to scroll up without fighting the view?
StructMapper | ReClass.NET & Class Layouts
The following users thanked StructMapper for this post:
LuaScripterX
Luau & Lua VM Reverser
VIP
Rep: 260
Join Date: Mar 2022
Posts: 20
Thanks: 68
2y ago · May 22, 2024 3:43 PM
#2
Check ImGui::GetScrollY() >= ImGui::GetScrollMaxY() before adding new items! If the user was already at the bottom, call ImGui::SetScrollHereY(1.0f) after rendering the new log entries. If the user scrolled up to inspect previous logs, skip the SetScrollHereY call so the view stays fixed.
LuaScripterX · Luau VM & Bytecode Engineering
PacketSniffer
Network Protocols & Sockets
MEMBER
Rep: 195
Join Date: Sep 2024
Posts: 22
Thanks: 49
2y ago · May 22, 2024 7:43 PM
#3
Also use ImGuiListClipper for large log lists (10,000+ items)! It only renders the visible lines on screen, preventing framerate drops.
PacketSniffer | Network Protocols & Winsock SPI