x

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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Clicking on an UMG widget takes the focus for keyboard inputs

Hello,

I'm using an UMG widget for my game's HUD. It has several buttons. When clicking on a button, then pressing "tab", it will select the next button/element in the widget. If I keep pressing "tab", it goes on. Which bothers me, because it means that once the HUD has been clicked somewhere, the keyboard inputs aren't received by the player controller/pawn.

I tried fixing it, two ways :

  1. Setting the "Can be focused" bool at false. Doesn't seem to change anything.

  2. Setting up the "Set Input Mode Game Only" node after the widget's construction. With this enabled (and the player's controller given as a parameter), I can only input one click/keyboard event, then every mouse input seems locked (EDIT : Actually, some mouse inputs go through. Not a lot, though). This issue might be related to the fact that I handle inputs in the player's pawn, and not in its controller (since there won't be any (de)possessing of any sort). I tried to add a hook in the (unused) player controller, and with this "Set Input Mode Game Only" node set, after the initial input, some mouse inputs are received, but a lot of them aren't (some by the player's controller, none by its pawn). Note : The keyboard input events are still received.

Any idea where this could be coming from? Is there a third way to prevent the UMG widget to take the focus in any way?

Thanks in advance.

Product Version: UE 4.12
Tags:
more ▼

asked Jul 14 '16 at 07:42 PM in Using UE4

avatar image

Nepho
8 3 3 6

avatar image M.FatihSaglam Jun 16 '18 at 12:20 PM

Hi there people. If anyone still interested how to do this, I can show my way.

If you save your last focused object to a variable, you can use it for focusing back to it when you lose focus. For example; First of all, you should focus your first button on your main menu I guess. alt text Second, you should highlight all of your buttons or sliders when they are focused. alt text BUT ! You need to set a variable which holds your last focused object referance. If you focused one of those at button array, you should save it. So when you lose focus, you can get back to it. alt text

The variable to save last widget is a Widget->ObjectReferance alt text

I hope these can help you people.

avatar image M.FatihSaglam Jun 16 '18 at 12:40 PM

And don't forget to set new keyboard focus, for example, when you switch to SINGLE PLAYER page by clicking or pressing on SINGLE PLAYER button from MAIN MENU page.

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

1 answer: sort voted first
  1. Can be focused to false should prevent a button from taking keyboard focus, otherwise there is a bug. Make sure you do this for every button

  2. I know that tab / shift tab has a bug currently in 4.12 where it can result in focusing widgets that do not support keyboard focus. I have reported it already. The best thing is to disable tab + shift tab behavior for now. You can overrule the navigation settings that are defined by default. I did that using the following code:

To register your own behavior have a look at the following classes/methods:

 SlateApplication.Get().SetNavigationConfig(MakeShareable(new FNavigationConfig()))) 

i use this method in my gameinstance init

FNavigationConfig -> defines if you want to respond to navigation requests when a key is pressed

You simply have to derive from FNavigationConfig and overrule virtual

 EUINavigation GetNavigationDirectionFromKey(const FKeyEvent& InKeyEvent) const
 {
   return EUINavigation::Invalid;
 }

This ensures slate never responds to keyboard navigation requests.

more ▼

answered Jul 15 '16 at 07:44 AM

avatar image

cageman
673 30 33 65

avatar image Nepho Jul 15 '16 at 08:11 AM

I tested something, and it's not only related to the tab input. After clicking a button, even pressing the arrow keys will make me navigate in the Uniform Grid Panel (that's what the buttons are in). I'll try what you're suggesting and report back, thanks for your answer !

avatar image cageman Jul 15 '16 at 08:21 AM

Ensure that all the buttons have IsFocusable = false.

avatar image Nepho Jul 15 '16 at 08:31 AM

Oh well. Pretty sure it comes from that. Let me check it out.

avatar image Nepho Jul 15 '16 at 08:32 AM

Yes, that was it! Thanks a lot :) It didn't occur to me that I had to do it for each button individually. You're awesome! Can you edit your original answer to add this suggestion so I can mark it as the correct answer?

avatar image cageman Jul 15 '16 at 08:34 AM

i added it!

avatar image Nepho Jul 15 '16 at 08:41 AM

Great. Thanks again! Good day to you!

(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