Coder Social home page Coder Social logo

Mouse scrolling not working about imgui HOT 6 OPEN

Thalenberghen avatar Thalenberghen commented on May 31, 2024
Mouse scrolling not working

from imgui.

Comments (6)

ocornut avatar ocornut commented on May 31, 2024

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

from imgui.

Thalenberghen avatar Thalenberghen commented on May 31, 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.

from imgui.

inobelar avatar inobelar commented on May 31, 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;
}

from imgui.

Thalenberghen avatar Thalenberghen commented on May 31, 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

from imgui.

ocornut avatar ocornut commented on May 31, 2024

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

from imgui.

Thalenberghen avatar Thalenberghen commented on May 31, 2024

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

from imgui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.