Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8203048

Magic mouse/trackpad scrolling injects shift modifier + inverted scroll values

    Details

      Description

      ADDITIONAL SYSTEM INFORMATION :
      JDK 1.8 u112 -> u171, JDK 1.9, JDK 10.0.1
      macOS High Sierra 10.13.4
      Macbook Pro with Magic Mouse/built-in trackpad/external Mac Trackpad

      A DESCRIPTION OF THE PROBLEM :
      When scrolling on macOS High Sierra using a magic mouse or a trackpad, Java dispatches several MouseWheelEvent instances with the shift key modifier and a scroll value that is the negative of what is expected.

      REGRESSION : Last worked in version 8u161

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Scroll in a Swing JPanel using a magic mouse or magic trackpad.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      - all modEx values are 0
      - all scroll values should be consistent with the scroll direction
      ACTUAL -
      - often events have a modEx value of 64
      - in this case, the scroll value is the negative of what is expected

      ---------- BEGIN SOURCE ----------
      Execute the following code and scroll on the panel:

        public static void main(String[] args) throws InvocationTargetException, InterruptedException {
          EventQueue.invokeAndWait(() -> {
            JFrame frame = new JFrame();
            JPanel content = new JPanel();
            content.setPreferredSize(new Dimension(100,100));
            content.addMouseWheelListener(e -> System.out.println("modEx: " + e.getModifiersEx() + " val:" + e.getPreciseWheelRotation()) );
            frame.add(content);
            frame.pack();
            frame.setVisible(true);
          });
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      ignore MouseWheelEvent instances with the shift modifier

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              serb Sergey Bylokhov
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: