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

Input Methods problem, Key Events not handled/received

XMLWordPrintable

    • x86
    • os_x

      FULL PRODUCT VERSION :


      ADDITIONAL OS VERSION INFORMATION :
      macOS Sierra Golden Master

      System Version: macOS 10.12 (16A319)
      Kernel Version: Darwin 16.0.0
      Boot Volume: Sierra

      A DESCRIPTION OF THE PROBLEM :
      Keyevents are not handled anymore when the method enableInputMethods is deactivated (called enableInputMethods(false)).





      REGRESSION. Last worked in version 8u112

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.8.0_102"
      Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the java program provided, press a button and hold it.
      If it is a button which, when hold, creates a small context window
      to choose a special letter (e.g ö)
      then, since the enableInputMethods is called with "false",
      we assume that though the window does not appear,
      it still receives all the keyevents, which is causing the wrong behaviour (but this is just our assumption).

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      All key events (typed,pressed, released) should be caught normally.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.BorderLayout;
      import java.awt.event.KeyEvent;
      import java.awt.event.KeyListener;
      import java.awt.im.InputContext;
      import java.util.Locale;

      import javax.swing.JFrame;
      import javax.swing.JTextField;


      public class SwingKeyboardTest {

      public static void main(String[] args) {
      JFrame frame = new JFrame("SwingKeyboardTest");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setLayout(new BorderLayout());
      JTextField textField = new JTextField();
      // Alternatively try to switch off composition mode
      InputContext inputContext = textField.getInputContext();
      if(inputContext != null) {
      try {
      inputContext.setCompositionEnabled(false);
      }
      catch(UnsupportedOperationException dsp_e) {
      dsp_e.printStackTrace();
      }
      }
      // Disable input methods entirely
      textField.enableInputMethods(false);
      textField.addKeyListener(new KeyListener() {
      public void keyPressed(KeyEvent kev) {
      System.out.println("keyPressed: kev=" + kev);
      System.out.println(" char=0x" + Integer.toHexString(kev.getKeyChar()) + "(" + (kev.getKeyChar() & 0xffff) + ")");
      kev.consume();
      }

      public void keyReleased(KeyEvent kev) {
      System.out.println("keyReleased: kev=" + kev);
      System.out.println(" char=0x" + Integer.toHexString(kev.getKeyChar()) + "(" + (kev.getKeyChar() & 0xffff) + ")");
      kev.consume();
      }

      public void keyTyped(KeyEvent kev) {
      System.out.println("keyTyped: kev=" + kev);
      System.out.println(" char=0x" + Integer.toHexString(kev.getKeyChar()) + "(" + (kev.getKeyChar() & 0xffff) + ")");
      kev.consume();
      }
      });
      frame.add(textField, BorderLayout.NORTH);
      frame.pack();
      frame.setVisible(true);
      }
      }

      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: