int32 FWebBrowserWindow::GetCefKeyboardModifiers(const FKeyboardEvent& KeyboardEvent) { int32 Modifiers = GetCefInputModifiers(KeyboardEvent); const FKey Key = KeyboardEvent.GetKey(); if (Key == EKeys::LeftAlt || Key == EKeys::LeftCommand || Key == EKeys::LeftControl || Key == EKeys::LeftShift) { Modifiers |= EVENTFLAG_IS_LEFT; } if (Key == EKeys::RightAlt || Key == EKeys::RightCommand || Key == EKeys::RightControl || Key == EKeys::RightShift) { Modifiers |= EVENTFLAG_IS_RIGHT; } if (Key == EKeys::NumPadZero || Key == EKeys::NumPadOne || Key == EKeys::NumPadTwo || Key == EKeys::NumPadThree || Key == EKeys::NumPadFour || Key == EKeys::NumPadFive || Key == EKeys::NumPadSix || Key == EKeys::NumPadSeven || Key == EKeys::NumPadEight || Key == EKeys::NumPadNine) { Modifiers |= EVENTFLAG_IS_KEY_PAD; } return Modifiers; }
void FWebBrowserWindow::OnKeyChar(const FCharacterEvent& InCharacterEvent) { if (IsValid()) { CefKeyEvent KeyEvent; KeyEvent.windows_key_code = InCharacterEvent.GetCharacter(); // 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_CHAR; KeyEvent.modifiers = GetCefInputModifiers(InCharacterEvent); InternalCefBrowser->GetHost()->SendKeyEvent(KeyEvent); } }
int32 FWebBrowserWindow::GetCefMouseModifiers(const FPointerEvent& InMouseEvent) { int32 Modifiers = GetCefInputModifiers(InMouseEvent); if (InMouseEvent.IsMouseButtonDown(EKeys::LeftMouseButton)) { Modifiers |= EVENTFLAG_LEFT_MOUSE_BUTTON; } if (InMouseEvent.IsMouseButtonDown(EKeys::MiddleMouseButton)) { Modifiers |= EVENTFLAG_MIDDLE_MOUSE_BUTTON; } if (InMouseEvent.IsMouseButtonDown(EKeys::RightMouseButton)) { Modifiers |= EVENTFLAG_RIGHT_MOUSE_BUTTON; } return Modifiers; }
bool FCEFWebBrowserWindow::OnKeyChar(const FCharacterEvent& InCharacterEvent) { if (IsValid() && !bIgnoreCharacterEvent) { PreviousCharacterEvent = InCharacterEvent; CefKeyEvent KeyEvent; #if PLATFORM_MAC KeyEvent.character = InCharacterEvent.GetCharacter(); #else KeyEvent.windows_key_code = InCharacterEvent.GetCharacter(); #endif KeyEvent.type = KEYEVENT_CHAR; KeyEvent.modifiers = GetCefInputModifiers(InCharacterEvent); InternalCefBrowser->GetHost()->SendKeyEvent(KeyEvent); return true; } return false; }