Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to always have keyboard focus on UI widgets?

I'm trying to find a way to have a bunch of widgets (mostly buttons) on the screen that the user can use the arrow keys to select and the enter key to press, while simultaneously being able to interact with the 3D scene through mouse clicks and other keys.

I have the input mode set to Game and UI, and when I click in the 3D scene (not on a widget) the widgets lose keyboard focus and you have to click on them again before you can use the arrow keys. Is there any way I can force the UI to always have keyboard focus?

Product Version: UE 4.15
more ▼

asked Oct 30 '15 at 11:59 PM in Using UE4

avatar image

61 4 5 14

avatar image virtual_nomak Mar 22 '16 at 12:28 AM

I came upon this question and I'm also interested to know the answer.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

This may sounds weird but set the controller for Game only instead. Setting it for UI seems to enable the mouse to input into the UI space. which is removing the focus and setting it to the clicked area on the viewport instead. It can also locks the character from operation he camera normally without left clicking. As the controller is trying to decide the inputs between the UI and game space.

more ▼

answered Jul 15 '16 at 11:47 PM

avatar image

26 1 2 2

avatar image jeff2365 Apr 29 '17 at 05:03 AM

Unfortunately this only seems to work until the user clicks. The user can move the camera around, but once they click the UI still loses focus.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

I needed to add an OnNativeTick method in parent widget that checks for focused widget. If none is focused reset focus to defined default widget (e.g. first button in menu). You can also do it in BP.

 void UBaseMenuUserWidget::NativeTick(const FGeometry& MyGeometry, float InDeltaTime) {     Super::NativeTick(MyGeometry, InDeltaTime); APlayerController* PC = GetOwningPlayer(); if (PC && InitFocusWidget && !HasUserFocusedDescendants(PC)) {InitFocusWidget->SetUserFocus(PC);} }
more ▼

answered Jan 29 '19 at 01:58 PM

avatar image

244 3 42 18

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question