0

I have detected some weird behavior of some Java software on OS X with a Magic Trackpad. I could detect that the magic lies in that when a horizontal "two-finger" scroll is performed, the modifiers constant of the MouseWheelEvent is set to 1, which is the equivalent to the InputEvent.SHIFT_MASKand thus causes the application to behave as if the user had SHIFT pressed.

How can I distinguish a horizontal scroll on the Magic Trackpad from a common SHIFT+Mouse Wheel? Using the InputEvent.SHIFT_DOWN_MASK apparently deactivates the detection of SHIFT down altogether.

Here is a code snippet that behaves as described above:

@Override
public void mouseWheelMoved(@NotNull MouseWheelEvent e) {
    int unitsToScroll = e.getUnitsToScroll();

    int modifiers = e.getModifiers();
    boolean shiftDown = ((modifiers & InputEvent.SHIFT_MASK) != 0);
    boolean ctrlDown = ((modifiers & InputEvent.CTRL_MASK) != 0);
    [...]
}

This is causing me a lot of headache to resolve.. Thank you for any help - it will be much appreciated

dmeu
  • 3,842
  • 5
  • 27
  • 43

1 Answers1

0

From my test it seems that if the distance of your 2 fingers changed (a pinch like operation) during the swipe the shift key mask will set. If you can keep your fingers strictly same distance the shift key mask will never being set.

dgao
  • 1