<AWT Dev> [8] Review request for 7197619 Using modifiers for the dead key detection on Windows
Oleg Pekhovskiy
oleg.pekhovskiy at oracle.com
Fri Sep 14 10:11:35 PDT 2012
Hi Alexander,
here are my comments:
1. Why did you decide to make WindowsKeyToJavaChar void? Maybe it takes
sense to leave signature closer to its original look?
2. Seems like WindowsKeyToJavaChar method could be simplifed (ToAsciiEx
-> ToUnicodeEx, remove MultiByteToWideChar),
like this:
3504 WORD wChar[2];
3505 UINT scancode = ::MapVirtualKey(wkey, 0);
3506 int converted = ::ToUnicodeEx(wkey, scancode, keyboardState,
3507&wChar, 2, 0, GetKeyboardLayout());
3508
3509 UINT translation;
3510 BOOL deadKeyFlag = (converted == 2);
3511
3512 // Dead Key
3513 if (converted< 0) {
3514 translation = java_awt_event_KeyEvent_CHAR_UNDEFINED;
3515 } else
3516 // No translation available -- try known conversions or else punt.
3517 if (converted == 0) {
3518 if (wkey == VK_DELETE) {
3519 translation = '\177';
3520 } else
3521 if (wkey>= VK_NUMPAD0&& wkey<= VK_NUMPAD9) {
3522 translation = '0' + wkey - VK_NUMPAD0;
3523 } else {
3524 translation = java_awt_event_KeyEvent_CHAR_UNDEFINED;
3525 }
3526 } else
3527 // the caller expects a Unicode character.
3528 if (converted> 0) {
3533 translation = wChar[0];
3534 }
Thanks,
Oleg
9/11/2012 5:24 PM, Alexander Scherbatiy wrote:
>
> bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7197619
> webrev: http://cr.openjdk.java.net/~alexsch/7197619/webrev.00/
>
> Only a virtual key code is used for the dead key detection on Windows
> in the current implementation.
> This does not take into account that dead keys can be pressed with
> modifiers like ctrl+alt+2 (caron dead key) on Hungarian keyboard.
>
> The fix gets isDeadKey flag and a character from the ToAsciiEx method
> and uses them for the windows dead key to java key translation.
>
> Thanks,
> Alexandr.
>
More information about the awt-dev
mailing list