JDK-4138877 : JDK1.1.6: Solaris: Keyboard events are inproperly generated.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt:i18n
  • Affected Version: 1.1.6,1.1.7
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_2.5.1,solaris_2.6
  • CPU: sparc
  • Submitted: 1998-05-15
  • Updated: 1998-08-11
  • Resolved: 1998-08-11
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
1.1.7 b01Fixed
Related Reports
Duplicate :  
Relates :  
Description

Name: moC74494			Date: 05/15/98


Start applet, hit tab to shift keyboard focus to label.
Press 'Shift' then 'z'

No KEY_PRESSED event is generated for the 'z' key.

Pressing 'Control' then 'z' will generate a PRESSED event for the 'z' key properly.

Also to note, the order of PRESSED/TYPED/RELEASED events has changed from 1.1.5
1.1.5 generated the PRESSSED event then the TYPED event then the RELEASE.
1.1.6 generates the TYPED event then the PRESSED then the RELEASED.

Sample run of applet.
-------------------------------
ares% appletviewer ki.html
Released = java.awt.event.KeyEvent[KEY_RELEASED,keyCode=9,Tab] on label1
Pressed = java.awt.event.KeyEvent[KEY_PRESSED,keyCode=16,keyChar='?'] on label1
Typed = java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyChar='Z'] on label1
Released = java.awt.event.KeyEvent[KEY_RELEASED,keyCode=90,keyChar='Z',modifiers=Shift] on label1
Released = java.awt.event.KeyEvent[KEY_RELEASED,keyCode=16,keyChar='',modifiers=Shift] on label1
-------------------------------


-ki.html-------------8<--------------------------------------

<applet code=KeyInput width=300 height=300>
</applet>

--------8<--------------------------------------

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

public class KeyInput extends Applet implements KeyListener
{
    public void init() {
        Label x = new Label("Type Here");
        add(x);
        x.addKeyListener(this);
    }

    public void keyTyped(KeyEvent e) {
        System.out.println("Typed = " + e);
    }

    public void keyPressed(KeyEvent e) {
        System.out.println("Pressed = " + e);
    }

    public void keyReleased(KeyEvent e) {
        System.out.println("Released = " + e);
    }
}
---------------------8<-------------------------------------
(Review ID: 29912)
======================================================================

jukka.tammisto@canada 1998-06-19

Description (including a test case) from incident 33937:
--------------------------------------------------------
Run the following program. Typing in the box without
pressing shift will generate keyevents. With shift pressed,
nothing happens.

This only happens in 1.1.6 - it works ok in 1.1.5 and 1.2beta3.
---


package bugs;

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

/** 
 * The following program will print out the incoming key events. 
 * On Solaris 2.5.1, jdk1.1.6, no key events will be generated if the
 * shift key has been pressed - ie, no upper case characters can be input.
 * jdk1.1.5 works correctly, as does jdk1.2beta3
 */
public class ShiftBug extends Canvas {
    public ShiftBug() {
	setSize(100,100);
	addMouseListener(new MyMouseListener());
	addKeyListener(new MyKeyListener());
    }

    public class MyMouseListener extends MouseAdapter {
	public void mouseEntered(MouseEvent evt) {
	    requestFocus();
	}
    }

    public class MyKeyListener extends KeyAdapter {
	public void keyPressed(KeyEvent evt) {
	    System.out.println("got " + evt);
	}
    }

    public static void main(String[] args) {
	Frame f = new Frame("ShiftBug");
	f.add(new ShiftBug());
	f.setSize(100,100);
	f.setVisible(true);
    }
}

jukka.tammisto@canada 1998-06-19

Output in JDK-1.1.5
-------------------
The I one is for 'Shift' and the II is for 'A'.

got java.awt.event.KeyEvent[KEY_PRESSED,keyCode=16,keyChar=''] on canvas0
got java.awt.event.KeyEvent[KEY_PRESSED,keyCode=65,keyChar='A',modifiers=Shift] on canvas0

Output in JDK-1.1.6 and JDK-1.1.7
---------------------------------
The output is for 'Shift', no output for 'A'.

got java.awt.event.KeyEvent[KEY_PRESSED,keyCode=16,keyChar='?'] on canvas0



Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.1.7 FIXED IN: 1.1.7 INTEGRATED IN: 1.1.7
14-06-2004

EVALUATION Date: Wed, 5 Aug 1998 18:36:45 -0700 (PDT) From: Mike Bronson <mbron@shorter> Subject: Re: Bug 4156752 To: okutsu@mbrons, senthils@mbrons Cc: prr@mbrons, mbron@shorter MIME-Version: 1.0 Content-MD5: 0pceuzpz/fDbWsm/gJVV+w== Please also take a look at the following bug: Bug 4138877 JDK1.1.6: Solaris: Keyboard events are inproperly generated. Mike Bronson mike.bronson@eng 1998-08-05 There is a problem in the code which was added to work around inconsistencies for Compose Key support between Solaris2.5.1 and 2.6. The code was replaced with the JDK1.2 code. masayoshi.okutsu@Eng 1998-08-06
06-08-1998

SUGGESTED FIX *** /tmp/geta9840 Thu Aug 6 19:29:47 1998 --- awt_InputMethod.c Thu Aug 6 15:19:13 1998 *************** *** 178,183 **** --- 178,184 ---- Hjava_lang_String * javastr; XIC ic; Bool result = True; + static Bool composing = False; pX11IMData = (X11InputMethodData *)PDATA(X11InputMethodData, currentX11InputMethodInstance); *************** *** 213,220 **** printf ("lookupString: status=XLookupBoth, keysym=0x%x",keysym); printf ("str = %s len=%d\n", buf, mblen); */ ! *keysymp = keysym; ! result = False; /*FALLTHRU*/ case XLookupChars: /* --- 214,227 ---- printf ("lookupString: status=XLookupBoth, keysym=0x%x",keysym); printf ("str = %s len=%d\n", buf, mblen); */ ! if (!composing) { ! if (keysym < 128 || ((keysym & 0xff00) == 0xff00)) { ! *keysymp = keysym; ! result = False; ! break; ! } ! } ! composing = False; /*FALLTHRU*/ case XLookupChars: /* *************** *** 238,245 **** printf("state=%x, keycode=%x, ",event->xkey.state,event->xkey.keycode); printf("keysym=%x\n", keysym); */ ! *keysymp = keysym; ! result = False; break; case XLookupNone: --- 245,256 ---- printf("state=%x, keycode=%x, ",event->xkey.state,event->xkey.keycode); printf("keysym=%x\n", keysym); */ ! if (keysym == XK_Multi_key) ! composing = True; ! if (! composing) { ! *keysymp = keysym; ! result = False; ! } break; case XLookupNone: *** /tmp/geta9931 Thu Aug 6 19:57:20 1998 --- canvas.c Thu Aug 6 19:57:13 1998 *************** *** 610,628 **** Modifiers mods = 0; Boolean printable = FALSE; - /* - * If Window is connected to IME awt_X11inputmethod_LookupString extracts - * composed character or committed string and sends KeyTyped(1.1.6) and - * InputEvent (1.2) event to application.It also returns keysyms. - * The keysyms are sent as KeyPress events to application. - - * If user press character 'a' in C locale awt_X11inputmethod_LookupString - * sends KeyTyped Event with keyChar='a' and returns keysym=XK_a. - * keysymtoAWTKeyCode translates XK_a to VK_A and sends keyPress event. - - * If Window is not connected to IME, keycode is converted into keysym - * and keyPress and keyTyped events are sent to application - */ if ((currentX11InputMethodInstance != NULL) && (keyEventId == java_awt_event_KeyEvent_KEY_PRESSED)) { /* --- 610,615 ---- *************** *** 632,655 **** *cont = FALSE; return; } ! keysymToAWTKeyCode(keysym, &keycode, &printable); ! if (keycode > 0) ! awt_post_java_key_event(client_data, keyEventId, ! (passEvent==TRUE) ? (long)awt_copyXEvent(event) : (long)0, ! int2ll(event->xkey.time), keycode, ! (unicode)keysym, modifiers); ! ! return; ! } - /* Get keysym without taking modifiers into account first to map - * to AWT keyCode table. - */ - keysym = XKeycodeToKeysym(event->xkey.display, event->xkey.keycode, 0); if (keysym == NoSymbol) { ! *cont = TRUE; ! return; } /* printf("---> KeyEvent %d: xkeycode=%x, state=%x xkeysym=%x\n", --- 619,634 ---- *cont = FALSE; return; } ! } else { ! /* Get keysym without taking modifiers into account first to map ! * to AWT keyCode table. ! */ ! keysym = XKeycodeToKeysym(event->xkey.display, event->xkey.keycode, 0); } if (keysym == NoSymbol) { ! *cont = TRUE; ! return; } /* printf("---> KeyEvent %d: xkeycode=%x, state=%x xkeysym=%x\n", masayoshi.okutsu@Eng 1998-08-06
06-08-1998