Skip to content

Chat & keyboard focus

Use case: pressing a key opens a React chat input that should immediately accept typing.

The supported pattern

  • Open chat: BP switches to UIOnly (or GameAndUI) input mode, ensures the chat layer is visible.
  • Close chat: pressing Esc or submitting (Enter) — the React side sends a chat:closed event back; BP returns input mode to GameOnly.
text
Event Open Chat
  ├─ Set Input Mode UI Only
  └─ Add Web HUD ("Chat", "http://localhost:5173/chat", Center, (0,0), (0.6,0.3))

Event On Received ("chat:closed")
  ├─ Remove Web HUD By Name ("Chat")
  └─ Set Input Mode Game Only

Mac UE 5.7 — keyboard focus does not auto-route

Click-to-type required on Mac UE 5.7

Setting Slate keyboard focus on a HUD widget (so the React <input> receives keystrokes without a click) does NOT work on Mac UE 5.7. A physical mouse click into the input is required to start typing. Esc/Enter close paths are unaffected once the input has been clicked once.

Tried and didn't help on Mac 5.7:

  • UWidget::SetKeyboardFocus() on the HUD widget after switching input mode
  • UWebHUDWidget::NativeOnFocusReceived forwarding FReply::SetUserFocus(SWebBrowser)
  • SetIsFocusable(true)

Slate focus reaches the widget, but the Slate→CEF keyboard routing is broken on Mac UE 5.7 (the same regression family as transparency). Works on Windows and UE 5.6.1.

Workaround

Accept one click-to-type on Mac 5.7. Auto-focus is expected to work again on UE 5.8.

Released under the MIT License.