-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
MouseWheel vs track pad (macOS) #6103
Comments
|
So I ran the tool you suggested, and there is no real difference in terms of value: both produce value of 0.1 for each event. What is different is the timing. With the real mouse wheel I get one event per "notch", but with the track pad, of course I get one event (of the same amplitude) per frame during the entire swipe.
I ran another test, in which I move the mouse wheel really fast (several notches up without stopping in between):
In this case, the values are getting bigger (in absolute terms) from frame to frame
|
Just to wrap up my findings:
// from ImGui::UpdateMouseWheel() method
// [...]
float max_step = window->InnerRect.GetHeight() * 0.67f;
float scroll_step = ImFloor(ImMin(5 * window->CalcFontSize(), max_step));
SetScrollY(window, window->Scroll.y - wheel.y * scroll_step); so clearly there is no "magic" or special handling whether it is a true mouse wheel or a track pad
auto mouseVerticalWheel = ImGui::GetIO().MouseWheel;
if(mouseVerticalWheel != 0)
{
auto zoomPercent = 1.0f - mouseVerticalWheel * 0.05f;
iCanvas.zoomBy(zoomPercent, iCanvas.getCanvasMousePos());
} The It works "naturally" both with a mouse wheel and a track pad! |
Although I know that
ImGui::GetIO().MouseWheel
is an internal API (lives inimgui.h
but under a section markedInternal
), I am using it to detect when the mouse wheel is used (see this issue #6051 (comment) I closed a few moments ago).The code I am using is something like:
On my mac desktop with a real mouse, when I use the mouse wheel and just go up/down one "notch" I just get one mouse wheel "event" and so it behaves really great.
On my mac laptop, using the 2 fingers swipe on the trackpad I get a ton of events thus making the zoom way too fast.
Thank you
The text was updated successfully, but these errors were encountered: