JDK-4193779 : Modifiers not delivered with KEY_TYPED events on Solaris.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.8,1.2.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,solaris_2.6
  • CPU: generic,sparc
  • Submitted: 1998-12-01
  • Updated: 1999-11-23
  • Resolved: 1999-04-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other
1.2.2_002 b02Fixed 1.3.0Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description

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)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: kestrel FIXED IN: 1.2.2-002 kestrel INTEGRATED IN: 1.2.2-002 kestrel-beta
14-06-2004

WORK AROUND Name: diC59631 Date: 12/01/98 Save modifiers in KEY_TYPED ? ======================================================================
11-06-2004

SUGGESTED FIX svdiffs 1.135 1.136 canvas.c 774,775c774 < (jchar) keysym, < 0); --- > (jchar) keysym, modifiers);
11-06-2004

EVALUATION Note that this bug only appears on Solaris, not Windows. Also note that the problem is in the native AWT code, and can be seen with native AWT components as well as Swing components. Also note that the original Synopsis and Description say that Shift modifiers are passed along with the event. This is not true: no modifiers are passed along. Also, this bug appears in 1.1.x, 1.2.x, and 1.3. The problem is simply that we are not passing the modifiers along when we post the Java event from the native code in canvas.c. Raising the priority to a P3 because it is the underlying cause of 4159610 on Solaris. eric.hawkes@eng 1999-04-06 Changed handleKeyEvent to pass modifiers along with keyTyped events. Note that this bug was identified as the cause of 4159610 on Solaris. After this fix, 4159610 no longer occurs on Solaris. Test case is at: /test/java/awt/event/KeyEvent/KeyModifiers/ eric.hawkes@eng 1999-04-08
08-04-1999