Skip to content

Commit 5049cad

Browse files
author
Anton Litvinov
committed
8230926: [macosx] Two apostrophes are entered instead of one with "U.S. International - PC" layout
Reviewed-by: serb, dmarkov
1 parent 861e1ad commit 5049cad

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,11 @@ void handleKeyEvent(int eventType, int modifierFlags, String chars, String chars
184184
// It is necessary to use testCharIgnoringModifiers instead of testChar for event
185185
// generation in such case to avoid uppercase letters in text components.
186186
LWCToolkit lwcToolkit = (LWCToolkit)Toolkit.getDefaultToolkit();
187-
if (lwcToolkit.getLockingKeyState(KeyEvent.VK_CAPS_LOCK) &&
188-
Locale.SIMPLIFIED_CHINESE.equals(lwcToolkit.getDefaultKeyboardLocale())) {
187+
if ((lwcToolkit.getLockingKeyState(KeyEvent.VK_CAPS_LOCK) &&
188+
Locale.SIMPLIFIED_CHINESE.equals(lwcToolkit.getDefaultKeyboardLocale())) ||
189+
(LWCToolkit.isLocaleUSInternationalPC(lwcToolkit.getDefaultKeyboardLocale()) &&
190+
LWCToolkit.isCharModifierKeyInUSInternationalPC(testChar) &&
191+
(testChar != testCharIgnoringModifiers))) {
189192
testChar = testCharIgnoringModifiers;
190193
}
191194

src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,23 @@ public Locale getDefaultKeyboardLocale() {
802802
return locale;
803803
}
804804

805+
public static boolean isLocaleUSInternationalPC(Locale locale) {
806+
return (locale != null ?
807+
locale.toString().equals("_US_UserDefined_15000") : false);
808+
}
809+
810+
public static boolean isCharModifierKeyInUSInternationalPC(char ch) {
811+
// 5 characters: APOSTROPHE, QUOTATION MARK, ACCENT GRAVE, SMALL TILDE,
812+
// CIRCUMFLEX ACCENT
813+
final char[] modifierKeys = {'\'', '"', '`', '\u02DC', '\u02C6'};
814+
for (char modKey : modifierKeys) {
815+
if (modKey == ch) {
816+
return true;
817+
}
818+
}
819+
return false;
820+
}
821+
805822
@Override
806823
public InputMethodDescriptor getInputMethodAdapterDescriptor() {
807824
if (sInputMethodDescriptor == null)

0 commit comments

Comments
 (0)