< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_Component.cpp

Print this page




3524     WORD wChar[2];
3525     int converted = 1;
3526     UINT ch = ::MapVirtualKey(wkey, 2);
3527     if (ch & 0x80000000) {
3528         // Dead key which is handled as a normal key
3529         isDeadKey = deadKeyActive = TRUE;
3530     } else if (deadKeyActive) {
3531         // We cannot use ::ToUnicodeEx if dead key is active because this will
3532         // break dead key function
3533         wChar[0] = shiftIsDown ? ch : tolower(ch);
3534     } else {
3535         UINT scancode = ::MapVirtualKey(wkey, 0);
3536         converted = ::ToUnicodeEx(wkey, scancode, keyboardState,
3537                                               wChar, 2, 0, GetKeyboardLayout());
3538     }
3539 
3540     UINT translation;
3541     BOOL deadKeyFlag = (converted == 2);
3542 
3543     // Dead Key
3544     if (converted < 0 || wChar[0] == 0 || isDeadKey) {
3545         translation = java_awt_event_KeyEvent_CHAR_UNDEFINED;
3546     } else
3547     // No translation available -- try known conversions or else punt.
3548     if (converted == 0) {
3549         if (wkey == VK_DELETE) {
3550             translation = '\177';
3551         } else
3552         if (wkey >= VK_NUMPAD0 && wkey <= VK_NUMPAD9) {
3553             translation = '0' + wkey - VK_NUMPAD0;
3554         } else {
3555             translation = java_awt_event_KeyEvent_CHAR_UNDEFINED;
3556         }
3557     } else
3558     // the caller expects a Unicode character.
3559     if (converted > 0) {
3560         translation = wChar[0];
3561     }
3562     if (ops == SAVE) {
3563         transTable.put(reinterpret_cast<void*>(static_cast<INT_PTR>(wkey)),
3564                        reinterpret_cast<void*>(static_cast<INT_PTR>(translation)));




3524     WORD wChar[2];
3525     int converted = 1;
3526     UINT ch = ::MapVirtualKey(wkey, 2);
3527     if (ch & 0x80000000) {
3528         // Dead key which is handled as a normal key
3529         isDeadKey = deadKeyActive = TRUE;
3530     } else if (deadKeyActive) {
3531         // We cannot use ::ToUnicodeEx if dead key is active because this will
3532         // break dead key function
3533         wChar[0] = shiftIsDown ? ch : tolower(ch);
3534     } else {
3535         UINT scancode = ::MapVirtualKey(wkey, 0);
3536         converted = ::ToUnicodeEx(wkey, scancode, keyboardState,
3537                                               wChar, 2, 0, GetKeyboardLayout());
3538     }
3539 
3540     UINT translation;
3541     BOOL deadKeyFlag = (converted == 2);
3542 
3543     // Dead Key
3544     if (converted < 0 || isDeadKey) {
3545         translation = java_awt_event_KeyEvent_CHAR_UNDEFINED;
3546     } else
3547     // No translation available -- try known conversions or else punt.
3548     if (converted == 0) {
3549         if (wkey == VK_DELETE) {
3550             translation = '\177';
3551         } else
3552         if (wkey >= VK_NUMPAD0 && wkey <= VK_NUMPAD9) {
3553             translation = '0' + wkey - VK_NUMPAD0;
3554         } else {
3555             translation = java_awt_event_KeyEvent_CHAR_UNDEFINED;
3556         }
3557     } else
3558     // the caller expects a Unicode character.
3559     if (converted > 0) {
3560         translation = wChar[0];
3561     }
3562     if (ops == SAVE) {
3563         transTable.put(reinterpret_cast<void*>(static_cast<INT_PTR>(wkey)),
3564                        reinterpret_cast<void*>(static_cast<INT_PTR>(translation)));


< prev index next >