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

Modifiers not set for KEY_TYPED events on win32

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.1.8
    • 1.1.8
    • client-libs
    • 1.1.8
    • generic
    • generic, windows_nt
    • Verified

        This is a regression introduced in win32 JDK 1.1.8 build F. The test case works fine on WinNT using 1.1.8 build E and 1.1.7B. As far as I can tell, the test does not pass on Solaris for any 1.1 version of the JDK (see e.g. 4174399).

        import java.awt.*;
        import java.awt.event.*;

        public class ModifierTest extends Frame implements KeyListener {

            public static void main(String args[]) {
                new ModifierTest();
            }

            public ModifierTest() {
                TextArea ta = new TextArea(8, 30);
                ta.addKeyListener(this);
                add(ta);
                pack();
                show();
            }

            public void keyPressed(KeyEvent evt) { }
            public void keyReleased(KeyEvent e) { }

            public void keyTyped(KeyEvent evt) {
                char keyChar = evt.getKeyChar();
                System.out.println("Key event = " + evt);
                System.out.println("Key mods = " + KeyEvent.getKeyModifiersText(evt.get
        Modifiers()));
                if ( evt.isShiftDown() ) {
                    System.out.println("Shift key is down");
                }
                if ( evt.isControlDown()) {
                    System.out.println("Control key is down");
                }
                if ( evt.isAltDown() ) {
                    System.out.println("Alt key is down");
                }
                if ( evt.isMetaDown() ) {
                    System.out.println("Meta key is down");
                }
            }

        }

        Example output from WinNT 4.0 SP3 when pressing Shift-A:

        D:\KeyTest\reg>C:\jdk118F-bin\jdk1.1.8\bin\java -classpath C:\jdk118F-bin\jdk1.1
        .8\lib\classes.zip;. ModifierTest
        Key event = java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyChar='A'] on text0
        Key mods =

        D:\KeyTest\reg>C:\jdk118E-bin\jdk1.1.8\bin\java -classpath C:\jdk118E-bin\jdk1.1
        .8\lib\classes.zip;. ModifierTest
        Key event = java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyChar='A',modifiers=Sh
        ift] on text0
        Key mods = Shift
        Shift key is down

        stuart.lawrence@eng 1999-02-08

              uwesunw Uwe Uwe (Inactive)
              slawson Stuart Lawson
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: