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

Mouse scrolling not working #7546

Open
Thalenberghen opened this issue May 1, 2024 · 6 comments
Open

Mouse scrolling not working #7546

Thalenberghen opened this issue May 1, 2024 · 6 comments

Comments

@Thalenberghen
Copy link

Version/Branch of Dear ImGui:

Version 1.90.5, Branch: master (master/docking/etc.), no modifications

Back-ends:

imgui_impl_opengl3.cpp + imgui_impl_sdl2.cpp

Compiler, OS:

Windows 10 + MSVC2022

Full config/build information:

No response

Details:

My Issue/Question:
I'm not quite sure when this started, since I never really have this situation much,
but I recently noticed that any kind of scrolling (e.g. of list-boxes) with the mouse wheel is not working for me.
This is also the case for the demo window.
I checked with the debugger, that the mousewheel event is emitted correctly (?, with wheel_y != 0).
I'm pretty sure this was working at some point. I have recently updated dearImGui but can't be sure if that broke it or if it was already broken before.
Any help would be greatly appreciated.
Same problem also happens with clang.

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

// Here's some code anyone can copy and paste to reproduce your issue
ImGui::Begin("Example Bug");
MoreCodeToExplainMyIssue();
ImGui::End();
@ocornut
Copy link
Owner

ocornut commented May 1, 2024

You will need to provide more details.
First try in to see if it happens official unmodified examples.

@Thalenberghen
Copy link
Author

Thalenberghen commented May 2, 2024

I compiled the unmodified opengl3/sdl2 example.
The behaviour is slightly different but still not working as expected.
Here is a video of what it looks like:
https://www.youtube.com/watch?v=dFMub49vs2g

The scrolling down produces some flickering as if it always resets to the top on the next frame.
Scrolling up instead directly jumps to the top.
I don't know if this information helps or what else I can/should provide.

@inobelar
Copy link

inobelar commented May 2, 2024

@Thalenberghen since you use SDL2 backend, you can try to add printf(stdout, "wheel x=%f, y=%f\n", wheel_x, wheel_y); fflush(stdout); to see what wheel x/y offsets passed into Dear ImGui. Put it before io.AddMouseWheelEvent(wheel_x, wheel_y) in imgui_impl_sdl2.cpp here:

case SDL_MOUSEWHEEL:
{
//IMGUI_DEBUG_LOG("wheel %.2f %.2f, precise %.2f %.2f\n", (float)event->wheel.x, (float)event->wheel.y, event->wheel.preciseX, event->wheel.preciseY);
#if SDL_VERSION_ATLEAST(2,0,18) // If this fails to compile on Emscripten: update to latest Emscripten!
float wheel_x = -event->wheel.preciseX;
float wheel_y = event->wheel.preciseY;
#else
float wheel_x = -(float)event->wheel.x;
float wheel_y = (float)event->wheel.y;
#endif
#ifdef __EMSCRIPTEN__
wheel_x /= 100.0f;
#endif
io.AddMouseSourceEvent(event->wheel.which == SDL_TOUCH_MOUSEID ? ImGuiMouseSource_TouchScreen : ImGuiMouseSource_Mouse);
io.AddMouseWheelEvent(wheel_x, wheel_y);
return true;
}

@Thalenberghen
Copy link
Author

Thalenberghen commented May 2, 2024

I have added the line, and interestingly it behaves like my program now, where nothing happens at all.
All the values it prints for wheel x and y are 0 or -0.

Edit:
I checked and the value for the event->wheel_y is showing +-1 as I would expect.
But the precise_y which it seems to pick up is 0 or a gigantic negative number.

image

@ocornut
Copy link
Owner

ocornut commented May 2, 2024

Use Demo>Debug Log>IO to visualize data received by dear imgui.

@Thalenberghen
Copy link
Author

So what's the verdict?
If I uncomment the preciseX/Y stuff and use the standard one everything works.
Should I just do that?

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