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

Modifiers not delivered with KEY_TYPED events on Solaris.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.2.2_002
    • 1.1.8, 1.2.0
    • client-libs
    • b02
    • generic, sparc
    • generic, solaris_2.6



        Name: diC59631 Date: 12/01/98


        import java.awt.event.KeyEvent;
        import java.awt.event.KeyListener;
         
        import com.sun.java.swing.JFrame;
        import com.sun.java.swing.JTextField;
         
        /** Modifiers (other than SHIFT) not delivered with KEY_TYPED.
          *
          * 1.2beta3 & 1.2beta4
          * Solaris 2.6, BUT NOT WinNT
          *
          * In the Solaris environment, the ALT, CTRL, & META modifiers are
          * never set in a KEY_TYPED KeyEvent for a Lightweight component.
          * They are set in a WinNT environment.
          *
          * Consequently, ALT-a causes an "a" to be entered in the JTextField
          * (& similar components) in the Solaris environment, but not with WinNT.
          * Also, mnemonic and accelerator keystrokes are sometimes entered in these
          * Components because of this. Also, there are other platform
          * inconsistencies with KEY_TYPED when you combine modifiers.
          *
          * Note that the KeyEvent API doc,
          * http://java.sun.com/products/jdk/1.2/docs/api/java/awt/event/KeyEvent.html
          * and the "Writing a KeyListener" tutorial,
          * http://java.sun.com/docs/books/tutorial/ui/components/keylistener.html,
          * state that KEY_TYPED is used when a combination of characters maps to
          * a Unicode character. So it is unclear whether a KEY_TYPED should be
          * sent at all. (Since when does ALT-a map to Unicode "a"?)
          *
          * But at the very least, the Solaris behavior should change
          * to match WinNT so that Components and Listeners can easily
          * recognize normal character input.
          *
          * ###@###.###
          */
        public class KeyEventDump implements KeyListener
        {
                public void keyPressed(KeyEvent e)
                {
                        System.err.println(e);
                }
                public void keyTyped(KeyEvent e)
                {
                        System.err.println(e);
                }
                public void keyReleased(KeyEvent e)
                {
                        System.err.println(e);
                }
         
                public static void main(String args[])
                {
         
                        JTextField text = new JTextField(10);
                        text.addKeyListener(new KeyEventDump());
         
                        JFrame frame = new JFrame();
                        frame.getContentPane().add(text);
         
                        frame.pack();
                        frame.show();
                }
        }
        (Review ID: 36497)
        ======================================================================

              ehawkessunw Eric Hawkes (Inactive)
              dindrigo Daniel Indrigo (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: