PlatformKeyboardEvent::PlatformKeyboardEvent(HWND, WPARAM code, LPARAM keyData, Type type, bool systemKey) : PlatformEvent(type, GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, false, ::GetTickCount() * 0.001) , m_text((type == PlatformEvent::Char) ? singleCharacterString(code) : String()) , m_unmodifiedText((type == PlatformEvent::Char) ? singleCharacterString(code) : String()) , m_keyIdentifier((type == PlatformEvent::Char) ? String() : keyIdentifierForWindowsKeyCode(code)) , m_windowsVirtualKeyCode((type == RawKeyDown || type == KeyUp) ? code : 0) , m_nativeVirtualKeyCode(m_windowsVirtualKeyCode) , m_macCharCode(0) , m_autoRepeat(HIWORD(keyData) & KF_REPEAT) , m_isKeypad(isKeypadEvent(code, keyData, type)) , m_isSystemKey(systemKey) { }
PlatformKeyboardEvent::PlatformKeyboardEvent(HWND, WPARAM code, LPARAM keyData, Type type, bool systemKey) : m_type(type) , m_text((type == Char) ? singleCharacterString(code) : String()) , m_unmodifiedText((type == Char) ? singleCharacterString(code) : String()) , m_keyIdentifier((type == Char) ? String() : keyIdentifierForWindowsKeyCode(code)) , m_autoRepeat(HIWORD(keyData) & KF_REPEAT) , m_windowsVirtualKeyCode((type == RawKeyDown || type == KeyUp) ? code : 0) , m_isKeypad(isKeypadEvent(code, keyData, type)) , m_shiftKey(GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT) , m_ctrlKey(GetKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT) , m_altKey(GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT) , m_metaKey(false) , m_isSystemKey(systemKey) { }
WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { WebEvent::Type type = keyboardEventTypeForEvent(message); String text = textFromEvent(wparam, type); String unmodifiedText = unmodifiedTextFromEvent(wparam, type); String keyIdentifier = keyIdentifierFromEvent(wparam, type); int windowsVirtualKeyCode = static_cast<int>(wparam); int nativeVirtualKeyCode = static_cast<int>(wparam); bool autoRepeat = HIWORD(lparam) & KF_REPEAT; bool isKeypad = isKeypadEvent(wparam, lparam, type); bool isSystemKey = isSystemKeyEvent(message); WebEvent::Modifiers modifiers = modifiersForCurrentKeyState(); double timestamp = ::GetTickCount() * 0.001; // ::GetTickCount returns milliseconds (Chrome uses GetMessageTime() / 1000.0) return WebKeyboardEvent(type, text, unmodifiedText, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp); }
PlatformKeyboardEvent::PlatformKeyboardEvent( Type type , unsigned int winCharCode , unsigned int winKeyCode , bool isShiftKey , bool isCtrlKey , bool isAltKey , bool isMetaKey , bool isAutoRepeat ) // we populate m_text/m_unmodifiedText on keyDown as the charCode is needed by swf in HTML on mac : m_type(type) , m_text(winCharCode ? singleCharacterString(winCharCode) : String()) , m_unmodifiedText(winCharCode ? singleCharacterString(winCharCode) : String()) , m_keyIdentifier((type == Char) ? String() : keyIdentifierForWindowsKeyCode(winKeyCode)) , m_autoRepeat(isAutoRepeat) , m_windowsVirtualKeyCode(winKeyCode ? winKeyCode : 0) , m_isKeypad(isKeypadEvent(winKeyCode, /*keyData,*/ type)) , m_shiftKey(isShiftKey) , m_ctrlKey(isCtrlKey) , m_altKey(isAltKey) , m_metaKey(isMetaKey) { }