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 do I set user focus to allow menu navigation?

I have a menu UI that I'm trying to allow a gamepad/keyboard to navigate but I seem to be setting the user focus incorrectly.

this is what the inventory widget looks like, the inventory slots are custom widgets arranged in a uniform grid element.

alt text

and this is where im setting the user focus in the player controller, i have currently set the focus to be the entire inventory widget. this code occurs after the inventory widget is made visible.

alt text

when I play the game and bring up the inventory I cant navigate with the keyboard until I press one of the buttons with the mouse, how do I set it so I can navigate with the keyboard straight away?

Product Version: UE 4.12
screenshot007.jpg (177.3 kB)
screenshot008.jpg (70.0 kB)
more ▼

asked Apr 05 '17 at 07:01 PM in Blueprint Scripting

avatar image

34 6 10 16

(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first

Take a look at this video, it is for a gamepad UMG plugin, I haven't tested it out so I don't know if it works, but it is worth a try:


more ▼

answered Apr 05 '17 at 10:36 PM

avatar image

604 34 26 42

avatar image MeGaJ0eY Apr 06 '17 at 09:03 PM

thanks but unfortunately its not quite what I was looking for.

I need to know how to set the user focus properly so that the inventory can be navigated as soon as it's activated by the player.

(comments are locked)
10|2000 characters needed characters left

Did you ever find an answer to this? I'm having the same problem.

more ▼

answered Jun 24 '17 at 03:24 PM

avatar image

1 2 3 4

(comments are locked)
10|2000 characters needed characters left

My solution was to specify a default menu element to be focused to. When you create the widget you set user focus to that default widget. Additionally you can check on Tick if your menu didn't lose focus and refocus on default element if it did. Note that your buttons need to be UserWidgets and that it works well only in InputModeUIOnly, I'm struggling to make it work on InputModeGameAndUI. Here is C++ for that:


 #pragma once
 #include "Blueprint/UserWidget.h"
 #include "BaseMenuUserWidget.generated.h"
 class YOURGAME_API UBaseMenuUserWidget : public UUserWidget
         virtual void NativeTick(const FGeometry& MyGeometry, float InDeltaTime) override;
     UBaseMenuUserWidget(const FObjectInitializer& ObjectInitializer);
     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Init)
     UUserWidget* InitFocusWidget;
     UFUNCTION(BlueprintCallable, Category = Init)
     void SetInitFocusWidget(UUserWidget* InInitFocusWidget);


 #include "SurvivalMode.h"
 #include "BaseMenuUserWidget.h"
 UBaseMenuUserWidget::UBaseMenuUserWidget(const FObjectInitializer & ObjectInitializer) : Super(ObjectInitializer)
     bCanEverTick = true;
     bShouldRefocusOnChildrenFocusLost = true;
 void UBaseMenuUserWidget::SetInitFocusWidget(UUserWidget * InInitFocusWidget)
     if (InInitFocusWidget) {
         InitFocusWidget = InInitFocusWidget;
         APlayerController* PC = GetOwningPlayer();
         if (PC) {
 void UBaseMenuUserWidget::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
     Super::NativeTick(MyGeometry, InDeltaTime);
     APlayerController* PC = GetOwningPlayer();
     if (PC && InitFocusWidget && !HasUserFocusedDescendants(PC)) {

Later you need to hook SetInitFocusWidget on Construct with a reference to default element.

alt text

more ▼

answered Jul 12 '17 at 08:57 AM

avatar image

224 3 42 18

avatar image ZimaXXX Jul 12 '17 at 09:32 AM

I also found out on how to check if your widget or anything in it is focused. Just check for bool value of HasAnyUserFocus || HasHasUserFocusedDescendants . If the focus is lost you can set it using SetUserFocus.

(comments are locked)
10|2000 characters needed characters left
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