Posted December 8, 20213 yr Hi Forum Members. I'm trying to detect the direction of the mouse scroll. I tried to do something like this, but I don't understand how event.getScrollDelta() works. This is something like an int variable, but in the source code I did not understand what it returns. My code: @SubscribeEvent public static void detectScroll(InputEvent.MouseScrollEvent event) { if (event.getScrollDelta() == DOWN) { // do something } else if(event.getScrollDelta() == UP) { // do something else } }
December 8, 20213 yr if the scrollDelta is positive it is scroll up, if it is negative it is scroll up means: if (event.getScrollDelta() > 0) { // UP } else if (event.getScrollDelta() < 0) { // DOWN } Edited December 8, 20213 yr by Luis_ST
December 8, 20213 yr Author 1 hour ago, Luis_ST said: if the scrollDelta is positive it is scroll up, if it is negative it is scroll up means: if (event.getScrollDelta() > 0) { // UP } else if (event.getScrollDelta() < 0) { // DOWN } Thanks for help, it's worked
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.