EVALUATION
From the submitter:
> You recently submitted a bug on this and in investigating it I have a
> question. Do you get similiar behavior for other Swing components,
> like a JButton subclass? For example, if you change your program to
> add a KeyListener to a JButton do you see the same behavior?
Same behaviour for JComponent and the following tested subclasses:
JTextField, JPanel, JButton. Both j2sdk1.3.1 and j2sdk1.4beta.
Just a brief reminder of the problems (Solaris 8, click to focus CDE
environment, Metal L&F).
No KEY_PRESSED events for the accented characters when mouse pointer over
window.
No KEY_PRESSED and KEY_TYPED events for the (ascii-range) accented
characters when mouse pointer outside of window.
Wrong keyChar in KEY_RELEASED events for the accented characters when mouse
pointer over window.
Wrong keyChar in KEY_PRESSED, KEY_TYPED and KEY_RELEASED events for the
(over ascii-range) accented characters when mouse pointer outside of window.
(Wrong keyChar means code page mapped (for example 337 > 245))
No keyCode present in received KEY_PRESSED and KEY_RELEASED events for the
accented characters.
j2sdk1.3.1 always provides correct results in these situations under the
Windows platform.
One additional info:
All the following environment variables are set to 'hu_HU.ISO8859-2':
LANG, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME
------
Based on this, it sounds like NO lightweight components are getting KeyEvents in this particular configuration, and thus it sounds like an awt issue.
###@###.### 2001-08-15
I'm not exactly sure why no keyPressed events are getting sent to the
lightweight components as described. However, the keyChar for keyPressed
and keyReleased events is not guaranteed to be meaningful. KeyTyped events
are for reporting character input: keyPressed and keyReleased events are not.
I think this is, at its root, requests to add keycodes for the French and
Hungarian keyboards.
The other issue mentioned is that the keyChar for KEY_TYPED events is
incorrect when the system is configured in a particular way, and the mouse
pointer is outside the window. That is a very strange result. I thought
I had seen something like it previously, but we were never able to track
down what the problem was.
###@###.### 2003-04-29
Name: osR10079 Date: 11/01/2003
I see two problems in this bugreport:
1. KEY_PRESSED is not generated for some special keys
2. KEY_TYPED has wrong key char for these keys
Here is my view of the problem:
At the begining of key event processing AWT asks input method if they want handle this event (if yes AWT do nothing).
In our case, when focus on lightweight component and user presses non-standard key, input methods want.
So, AWT does not generate any events relys on input methods. But, for some reasons, they do not generate
KEY PRESSED too (So, I think that the first problem is in the input methods code).
After that input methods creates InputMethodEvent (INPUT_METHOD_TEXT_CHANGED) and post it to Swing.
And then Swing creates corresponding KEY_TYPED for this event (see JTextComponent.replaceInputMethodText()).
So, it looks like, the cause of the second problem is in Swing.
Based on eveluation I reassign this bug to IM team for further investigation.
###@###.### 2003-11-2
======================================================================
The reason that the KEY_PRESSED for those special keys are not generated is that the underlying XIM is consuming the KeyPress XEvent. Here is the spec for XFilterEvent, which we call for input method processing:
If XFilterEvent returns True, then some input method has
filtered the event, and the client should discard the event.
And the case mentioned here definitely returns True from XFilterEvent. In summary, Java applications should not rely that KEY_PRESSED events are always passed for each key press, since the underlying input method may consume it. This holds true even on Windows platforms. For example, if the user is inputting East Asian scripts, such as Chinese, Japanese, or Korean, applications may not see all the KEY_PRESSED events while the text is in composition.
As to the other aspect of this bug, i.e, KEY_TYPED has wrong key char, there is not enough information on this bug report, and so far I could not reproduce the problem, i.e., I could successfully input those accented characters in Swing text components with the provided xmodmap table. If the problem still persists, please open another bug with a detailed information.
I am closing this bug as not a bug as the reason mentioned above.
###@###.### 2003-11-03
Further investigation revealed that XFilterEvent does not return True in this case. Reopening the bug.
###@###.### 2003-11-03
There is a piece of code in awt_x11inputmethod_lookupString(awt_InputMethod.c)
as follows:
switch (status) {
case XLookupBoth:
if (!composing) {
if (keysym < 128 || ((keysym & 0xff00) == 0xff00)) {
*keysymp = keysym;
result = False;
break;
}
}
I replaced that '128' with '0xff' so that it includes those accented keysyms,
and this particular problem seems to be solved. But the problem is that the
keysym returned from this function is overridden in handleKeyevent. In this
problem case, the keysym is overridden with the value from XKeycodeToKeysym,
which happened to be the same as the one that is returned from the IM code.
Since the keysym is generated just by the keyboard mapping, and no IM is involved.
But those accented characters can also be input with the input method. i.e.,
"Compose"+"a"+"'" generates a-acute. In this case, even though the IM code
returns a-acute keysym correctly, it would be overridden with the one from
XKeycodeToKeysym, which would return the keysym for the last apostrophe. So for
the "Compose" key sequence method, the keysym from the IM code should not be
overridden unconditionally.
###@###.### 2003-11-05
We decided to pull the fix for this problem from Tiger. Please see the bug report 5057184 for more detail. We expect a complete KeyEvent related fixes in Mustang.
###@###.### 2004-07-13
Should be fixed for XToolkit (default in Mustang) with umbrella bug 4360364.
###@###.### 2005-06-06 10:30:09 GMT
|