-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scroll parent window once child window is fully scrolled #8202
Comments
I guess this was mentioned in passing while we worked on #3795 but never implemented. |
To achieve the behavior where scrolling propagates from a child window to its parent window once the child has reached its scroll limit, you can use ImGui's public API along with some custom logic to manually handle the scroll. #include "imgui.h" void ScrollableParentChild()
} Separate Scroll Management: Both the parent and child windows are scrollable. While hovering the child window, check the ImGui::GetScrollY() and ImGui::GetScrollMaxY() values. Use ImGui::GetIO().MouseWheel to detect the scroll direction and apply it conditionally to the parent. The factor 20.0f in SetScrollY can be adjusted to control how much the parent scrolls per wheel tick. |
|
Version/Branch of Dear ImGui:
1.90.8
Back-ends:
imgui_impl_glfw.cpp + imgui_impl_opengl.cpp
Compiler, OS:
Windows
Full config/build information:
ImGui.NET
Details:
Can I scroll a parent window while hovering the child window?
I have a vertically scrollable window with a child window, which is also vertically scrollable.
Currently imgui chooses which window to scroll with the mouse wheel/touchpad based on which window the pointer is hovering.
However, there's a situation where this behavior alone creates a bit of an uncomfortable experience. If the child window is not fully visible in the viewport and you are trying to scroll to the bottom of the child window the scrolling stops once the child window is at the bottom. The bottom items are still not visible though, because the parent needs to be scrolled down a bit too. But to get the parent to scroll you have to move the pointer away from the child window and then scroll again.
I would like to achieve a behavior, where hovering over a child window and moving mouse wheel/touchpad scrolls the child window, but once you are fully scrolled to that direction it would start scrolling the parent window. This would eliminate the need move the pointer mid-scrolling.
The same situation can be shown in the demo window (attached a gif).
Can this be achieved with the current public API?
Screenshots/Video:
The text was updated successfully, but these errors were encountered: