Skip to content
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

How to scroll outer child when mouse is hovering on inner ones? #1502

Closed
paladin-t opened this issue Dec 14, 2017 · 10 comments
Closed

How to scroll outer child when mouse is hovering on inner ones? #1502

paladin-t opened this issue Dec 14, 2017 · 10 comments

Comments

@paladin-t
Copy link

paladin-t commented Dec 14, 2017

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

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.

@ocornut
Copy link
Owner

ocornut commented Dec 14, 2017

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 ?

@paladin-t
Copy link
Author

paladin-t commented Dec 14, 2017

Cause I'm trying to do this:

ss1

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

@ocornut
Copy link
Owner

ocornut commented Dec 14, 2017

So I think your problem is the same as
#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.

@paladin-t
Copy link
Author

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

@ocornut
Copy link
Owner

ocornut commented Dec 14, 2017

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.

@paladin-t
Copy link
Author

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

ocornut added a commit that referenced this issue Dec 14, 2017
…orwards the mouse wheel event to the parent window, unless either ImGuiWindowFlags_NoInputs or ImGuiWindowFlags_NoScrollbar are also set. (#1380, #1502)
@ocornut
Copy link
Owner

ocornut commented Dec 14, 2017

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."

@ocornut ocornut closed this as completed Dec 14, 2017
@OvermindDL1
Copy link

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?

@ocornut
Copy link
Owner

ocornut commented Dec 14, 2017

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

ocornut added a commit that referenced this issue Jul 22, 2018
… window if ImGuiWindowFlags_NoScrollWithMouse is set. (#1463, #1380, #1502)
ocornut added a commit that referenced this issue Jul 2, 2019
…tically forwarded to parent window if ScrollMax is zero on the scrolling axis. Also still 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 (amend #1502, #1380).
@ocornut
Copy link
Owner

ocornut commented Jul 2, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants