Imgui: How to scroll outer child when mouse is hovering on inner ones?

Created on 14 Dec 2017  路  10Comments  路  Source: ocornut/imgui

Hi, I got a question. I've made some nested children regions

~~cpp
ImGui::BeginChild();
ImGui::BeginChild();
...
ImGui::EndChild();
ImGui::EndChild();
~~

Is it possible to scroll outer child when mouse is hovering on inner ones, with mouse wheel?
Thanks.

scrolling

Most helpful comment

OK you can now use the ImGuiWindowFlags_NoScrollWithMouse flag and by default on a child window it will forward the mouse wheel to its parent.

"Using the ImGuiWindowFlags_NoScrollWithMouse flag on a child window forwards the mouse wheel event to the parent window, unless either ImGuiWindowFlags_NoInputs or ImGuiWindowFlags_NoScrollbar are also set."

All 10 comments

It's not possible, you can use ImGuiWindowFlags_NoScrollWithMouse flag on individual BeginChild() call but it will block the scrolling.

Why are you trying to do this? Does your second embedded child window has scrolling at all ?

Cause I'm trying to do this:

ss1

Inner is always expanded without scrolling, outer is the document.

So I think your problem is the same as
https://github.com/ocornut/imgui/issues/1496

You shouldn't use a child window for inner, it's really overkill.
But we ought to provide a mechanism to easily capture border a block of widget. Currently you may be able to use BeginGroup()+EndGroup() and draw a border. But I need to provide a simpler mechanism for that.

Sorry, not exactly. inner never scrolls vertically, but may horizontally. Group doesn't fit, it seems there's no better option for the moment.

I see. I think we could provide a solution in this case, by forwarding mouse scroll to the parent parent when ImGuiWindowFlags_NoScrollWithMouse is set.

Linking to #1380 for now.

Nice. Thanks for the tips, I'll make a trade off for now.

OK you can now use the ImGuiWindowFlags_NoScrollWithMouse flag and by default on a child window it will forward the mouse wheel to its parent.

"Using the ImGuiWindowFlags_NoScrollWithMouse flag on a child window forwards the mouse wheel event to the parent window, unless either ImGuiWindowFlags_NoInputs or ImGuiWindowFlags_NoScrollbar are also set."

OK you can now use the ImGuiWindowFlags_NoScrollWithMouse flag and by default on a child window it will forward the mouse wheel to its parent.

Does this include horizontal mouse scrolling?

There's no horizontal mouse scrolling at the moment, I have yet to look at the PR (#1463)

Note that I have amended this behavior today:

  • Mouse wheel scrolling while hovering a child window is automatically forwarded to parent window if ScrollMax is zero on the scrolling axis (so in a same position vertical mouse wheel can apply to a different window than the horizontal mouse wheel).
  • Also still he case if ImGuiWindowFlags_NoScrollWithMouse is set (not new), but previously the forwarding would be disabled if ImGuiWindowFlags_NoScrollbar was set on the child window, which is not the case any more. Forwarding can still be disabled by setting ImGuiWindowFlags_NoInputs.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

BlackWatersInc picture BlackWatersInc  路  3Comments

noche-x picture noche-x  路  3Comments

bogdaNNNN1 picture bogdaNNNN1  路  3Comments

NPatch picture NPatch  路  3Comments

KaungZawHtet picture KaungZawHtet  路  3Comments