Hello,

Could you please review the following fix for the bug.

Bug: https://bugs.openjdk.java.net/browse/JDK-8230926
Webrev: http://cr.openjdk.java.net/~alitvinov/8230926/jdk15/webrev.00

The bug consists in the fact that if on macOS with currently set "U.S. International - PC" keyboard layout a user presses any of 5 modifier keys: ' (APOSTROPHE), " (QUOTATION MARK), ` (ACCENT GRAVE), ˜ (SMALL TILDE), ˆ (CIRCUMFLEX ACCENT) and then presses any consonant Latin letter key, for example "p" key, then 2 consecutive modifier keys are entered in AWT or Swing text field and the consonant letter is not entered.

CAUSE OF THE BUG:

The second extra modifier key is entered in the text field instead of the required letter during execution of the function "(void) keyDown: (NSEvent *)event" in "src/java.desktop//macosx/native/libawt_lwawt/awt/AWTView.m" for "NSEvent" instance representing pressing on the consonant letter key, for example that "p" key, through the next sequence of function/method calls:

"(void) keyDown: (NSEvent *)event" - "AWTView.m" file.
|-> "(void) deliverJavaKeyEventHelper: (NSEvent *) event" - "AWTView.m" file
      |-> "sun.lwawt.macosx.CPlatformView.deliverKeyEvent(NSEvent)" - "CPlatformView.java" file             |-> "sun.lwawt.macosx.CPlatformResponder.handleKeyEvent" - "CPlatformResponder.java" file

The instance of "NSEvent" being handled which corresponds to press on the consonant letter key, for example "p", has the next values of its 2 important fields:

[event characters] = "'p"
[event charactersIgnoringModifiers] = "p"

The method "sun.lwawt.macosx.CPlatformResponder.handleKeyEvent" is designed in such a way that it selects only the first character of the string variable "chars" whose value in this case equals "'p" and generates Java AWT key events for " ' " character while ignoring presence of "p" character both in "chars" and "charsIgnoringModifiers" string variables.

FIX:

To change "sun.lwawt.macosx.CPlatformResponder.handleKeyEvent" method in such a way to let it generate AWT key events for a character from "charsIgnoringModifiers" string instead of the modifier key from the "chars" string, when "U.S. International - PC" keyboard layout is used.

Thank you,
Anton

Reply via email to