void FWebBrowserWindow::OnKeyDown(const FKeyboardEvent& InKeyboardEvent) { if (IsValid()) { CefKeyEvent KeyEvent; KeyEvent.windows_key_code = InKeyboardEvent.GetKeyCode(); // TODO: Figure out whether this is a system key if we come across problems /*KeyEvent.is_system_key = message == WM_SYSCHAR || message == WM_SYSKEYDOWN || message == WM_SYSKEYUP;*/ KeyEvent.type = KEYEVENT_RAWKEYDOWN; KeyEvent.modifiers = GetCefKeyboardModifiers(InKeyboardEvent); InternalCefBrowser->GetHost()->SendKeyEvent(KeyEvent); } }
void CWebCore::ProcessInputMessage ( UINT uMsg, WPARAM wParam, LPARAM lParam ) { if ( !m_pFocusedWebView || !( uMsg == WM_KEYDOWN || uMsg == WM_KEYUP || uMsg == WM_CHAR || uMsg == WM_SYSCHAR || uMsg == WM_SYSKEYDOWN || uMsg == WM_SYSKEYUP ) ) return; CefKeyEvent keyEvent; keyEvent.windows_key_code = wParam; keyEvent.native_key_code = lParam; keyEvent.modifiers = GetCefKeyboardModifiers ( wParam, lParam ); keyEvent.is_system_key = uMsg == WM_SYSCHAR || uMsg == WM_SYSKEYDOWN || uMsg == WM_SYSKEYUP; if ( uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN ) keyEvent.type = cef_key_event_type_t::KEYEVENT_RAWKEYDOWN; else if ( uMsg == WM_KEYUP || uMsg == WM_SYSKEYUP ) keyEvent.type = cef_key_event_type_t::KEYEVENT_KEYUP; else if ( uMsg == WM_CHAR || uMsg == WM_SYSCHAR ) keyEvent.type = cef_key_event_type_t::KEYEVENT_CHAR; m_pFocusedWebView->InjectKeyboardEvent ( keyEvent ); }
void FWebBrowserWindow::OnKeyUp(const FKeyEvent& InKeyEvent) { if (IsValid()) { CefKeyEvent KeyEvent; #if PLATFORM_MAC KeyEvent.native_key_code = InKeyEvent.GetKeyCode(); KeyEvent.character = InKeyEvent.GetCharacter(); #else KeyEvent.windows_key_code = InKeyEvent.GetKeyCode(); #endif // TODO: Figure out whether this is a system key if we come across problems /*KeyEvent.is_system_key = message == WM_SYSCHAR || message == WM_SYSKEYDOWN || message == WM_SYSKEYUP;*/ KeyEvent.type = KEYEVENT_KEYUP; KeyEvent.modifiers = GetCefKeyboardModifiers(InKeyEvent); InternalCefBrowser->GetHost()->SendKeyEvent(KeyEvent); } }
void FCEFWebBrowserWindow::PopulateCefKeyEvent(const FKeyEvent& InKeyEvent, CefKeyEvent& OutKeyEvent) { #if PLATFORM_MAC OutKeyEvent.native_key_code = InKeyEvent.GetKeyCode(); FKey Key = InKeyEvent.GetKey(); if (Key == EKeys::BackSpace) { OutKeyEvent.unmodified_character = kBackspaceCharCode; } else if (Key == EKeys::Tab) { OutKeyEvent.unmodified_character = kTabCharCode; } else if (Key == EKeys::Enter) { OutKeyEvent.unmodified_character = kReturnCharCode; } else if (Key == EKeys::Pause) { OutKeyEvent.unmodified_character = NSPauseFunctionKey; } else if (Key == EKeys::Escape) { OutKeyEvent.unmodified_character = kEscapeCharCode; } else if (Key == EKeys::PageUp) { OutKeyEvent.unmodified_character = NSPageUpFunctionKey; } else if (Key == EKeys::PageDown) { OutKeyEvent.unmodified_character = NSPageDownFunctionKey; } else if (Key == EKeys::End) { OutKeyEvent.unmodified_character = NSEndFunctionKey; } else if (Key == EKeys::Home) { OutKeyEvent.unmodified_character = NSHomeFunctionKey; } else if (Key == EKeys::Left) { OutKeyEvent.unmodified_character = NSLeftArrowFunctionKey; } else if (Key == EKeys::Up) { OutKeyEvent.unmodified_character = NSUpArrowFunctionKey; } else if (Key == EKeys::Right) { OutKeyEvent.unmodified_character = NSRightArrowFunctionKey; } else if (Key == EKeys::Down) { OutKeyEvent.unmodified_character = NSDownArrowFunctionKey; } else if (Key == EKeys::Insert) { OutKeyEvent.unmodified_character = NSInsertFunctionKey; } else if (Key == EKeys::Delete) { OutKeyEvent.unmodified_character = kDeleteCharCode; } else if (Key == EKeys::F1) { OutKeyEvent.unmodified_character = NSF1FunctionKey; } else if (Key == EKeys::F2) { OutKeyEvent.unmodified_character = NSF2FunctionKey; } else if (Key == EKeys::F3) { OutKeyEvent.unmodified_character = NSF3FunctionKey; } else if (Key == EKeys::F4) { OutKeyEvent.unmodified_character = NSF4FunctionKey; } else if (Key == EKeys::F5) { OutKeyEvent.unmodified_character = NSF5FunctionKey; } else if (Key == EKeys::F6) { OutKeyEvent.unmodified_character = NSF6FunctionKey; } else if (Key == EKeys::F7) { OutKeyEvent.unmodified_character = NSF7FunctionKey; } else if (Key == EKeys::F8) { OutKeyEvent.unmodified_character = NSF8FunctionKey; } else if (Key == EKeys::F9) { OutKeyEvent.unmodified_character = NSF9FunctionKey; } else if (Key == EKeys::F10) { OutKeyEvent.unmodified_character = NSF10FunctionKey; } else if (Key == EKeys::F11) { OutKeyEvent.unmodified_character = NSF11FunctionKey; } else if (Key == EKeys::F12) { OutKeyEvent.unmodified_character = NSF12FunctionKey; } else if (Key == EKeys::CapsLock) { OutKeyEvent.unmodified_character = 0; OutKeyEvent.native_key_code = kVK_CapsLock; } else if (Key.IsModifierKey()) { // Setting both unmodified_character and character to 0 tells CEF that it needs to generate a NSFlagsChanged event instead of NSKeyDown/Up OutKeyEvent.unmodified_character = 0; // CEF expects modifier key codes as one of the Carbon kVK_* key codes. if (Key == EKeys::LeftCommand) { OutKeyEvent.native_key_code = kVK_Command; } else if (Key == EKeys::LeftShift) { OutKeyEvent.native_key_code = kVK_Shift; } else if (Key == EKeys::LeftAlt) { OutKeyEvent.native_key_code = kVK_Option; } else if (Key == EKeys::LeftControl) { OutKeyEvent.native_key_code = kVK_Control; } else if (Key == EKeys::RightCommand) { // There isn't a separate code for the right hand command key defined, but CEF seems to use the unused value before the left command keycode OutKeyEvent.native_key_code = kVK_Command-1; } else if (Key == EKeys::RightShift) { OutKeyEvent.native_key_code = kVK_RightShift; } else if (Key == EKeys::RightAlt) { OutKeyEvent.native_key_code = kVK_RightOption; } else if (Key == EKeys::RightControl) { OutKeyEvent.native_key_code = kVK_RightControl; } } else { OutKeyEvent.unmodified_character = InKeyEvent.GetCharacter(); } OutKeyEvent.character = OutKeyEvent.unmodified_character; #else OutKeyEvent.windows_key_code = InKeyEvent.GetKeyCode(); #endif OutKeyEvent.modifiers = GetCefKeyboardModifiers(InKeyEvent); }