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"

Gamepad/Keyboard navigation in UMG menus?

Hi!

I'm trying to use UMG for my game menus but my game is suposed to be used with gamepad and I don't know how to bind the keyboard/Gamepad buttons to move along the menus.

In the 4.6 release it is suposed that we can do it:

UI: GAME CONTROLLER SUPPORT

You can now navigate between UI elements using a joystick!

By default you can use the arrow keys, directional pad or left joystick to navigate. You can still use Tab or Shift+Tab as well. This works with both Slate and Unreal Motion Graphics. We’ve unified the concept of “Keyboard Focus” and “Controller Focus” into “User Focus”. Changing user focus will affect all controllers and keyboards for that user.

Am I missing something?

Can someone make a little tutorial on how to achieve this?

I've tried to search documentation about this but i didn't find anything useful for me.

Product Version: Not Selected
Tags:
more ▼

asked Dec 15 '14 at 05:15 PM in Using UE4

avatar image

iscaru1988
211 7 13 20

avatar image TheFoyer Dec 15 '14 at 05:20 PM

I too am interested in this information. For now I handle all the states manually, and when a controller/keyboard direction is hit the player controller fires an event on the widget that will check which option you currently have selected, and which one should be selected next. It's not ideal for sure. Then I have to handle the hover/pressed states of the button manually.

avatar image CHADALAK1 Jan 19 '15 at 08:06 PM

I also am interested in this information.... Really would like to know what is needed to do this

avatar image cgrebeld Jan 30 '15 at 06:33 PM

Me too.. in what case does this actually work?

avatar image CaptainMcMarcus Jan 31 '15 at 01:40 PM

The closest I've been able to get this is by putting a bunch of buttons into a vertical container and then when you click anywhere inside the container you can then cycle through the buttons on your controller. It's a bit impractical but it's the closest I've got to get it working. I'm also interested in working out how to get it working without having to do clicks.

avatar image Unhek Jan 31 '15 at 10:36 PM

I also am trying this, I think its not really implemented properly yet so far,

What I do is in c++ grab the widget I want TakeWidget() and then use SlateOperations.SetUserFocus() to set the focus to that widget, this lets me use my gamepad, although I have no idea how to change the visuals of that dashed edge you get. My guess is we have to either learn Slate or wait for better support for UWidgets

avatar image cgrebeld Feb 10 '15 at 02:19 PM

I ended up doing it all manually in c++. I keep a navigation ring of button pointers and manually set the 'hover' state of all my buttons (at the slate level) depending on the gamepad input events.

It works perfectly with gamepad and mouse/keyboard, but of course it would be awesome if the built-in navigation system actually worked!

avatar image echoform Feb 19 '15 at 12:38 AM

Hi Cgrebeld, so did you bind some function to "W"(some key) with function and in the function you invoke like "OnClicked" event of UMG Widget's button? How would I get pointer to a button of the UMG widget in code?

Could you provide simple work flow of code?

avatar image kshepitzki Feb 18 '15 at 06:48 AM

Hi cgrebeld, I am trying to do the exact same thing, any chance of sharing your solution? Thanks

avatar image VeerChidar May 01 '15 at 02:02 AM

I am looking for the same thing... does anyone have solution?

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

8 answers: sort voted first

Update: this works with a gamepad as well (tested with an Xbox controller)

I can navigate with keyboard up/down keys using this setup:

Level/character blueprint: alt text in UMG widget (optional, if you want to customize appearance): alt text

The result (it would be nice if we could change the default "dotted line" focused look): alt text

keyboard nav.png (335.9 kB)
keyboard1.png (75.3 kB)
keyboard2.png (117.5 kB)
more ▼

answered May 16 '15 at 02:55 PM

avatar image

CodeSpartan
271 12 113 34

avatar image DevilEye May 16 '15 at 04:19 PM

@CodeSpartan Not working for me, I have placed my buttons in 'Horizontal Grid' and have added different images for Normal, Hovered and Clicked state under Style section. Even unchecked 'Is Focusable' under interaction section. Further I tried checking 'Has Keyboard Focus' which always returns 'False'. I am not able to have keyboard focused on the button, any assistance please.

avatar image CodeSpartan May 17 '15 at 07:55 AM

I've uploaded a sample project: https://copy.com/OWm8XLDSo28TRZ7e

avatar image DevilEye May 17 '15 at 08:06 AM

Hey thanks for the sample project, downloading started :) Yes got it working. :)

avatar image SkeetonYu Aug 23 '15 at 01:28 PM

What did you do to get it working? I'm at the same problem as you had before.

avatar image SkeetonYu Aug 23 '15 at 01:31 PM

Nvm, one of my wire was mixed up.

avatar image Imsopov Jul 16 '15 at 12:02 AM

Thank you, this helped me also.

avatar image Kiwikah Inc Jun 14 '16 at 01:54 AM

The link is broken =/ Really excited to check out the sample project to see how you did this! Really stuck trying to figure out how to program the "continue" with the gamepad - don't even really need to program every option to a key on the gamepad - just simply have it when I hit "any key" it goes next (for cinematic) any help would be very much appreciated

avatar image Imagine-Games Jan 24 '17 at 02:04 AM

updated link for 2017 please?! :)

avatar image Raed Abbas Jun 06 '15 at 03:53 PM

So basically there's no such thing as "You can now navigate between UI elements using a joystick!" am I right?

avatar image CodeSpartan Jun 11 '15 at 05:13 PM

I've just tried my sample project with an Xbox controller - you can both navigate and press buttons. You can download it from the link above and check for yourself.

avatar image SkeetonYu Aug 23 '15 at 04:09 PM

Is there a way to get rid of the dotted square?

avatar image keyle Apr 04 '16 at 07:56 AM

As of 4.8: Project Settings / User Interface / RenderFocusRule (Set To) Never

avatar image SwarmHammer Oct 13 '15 at 08:33 PM

will mouse clicks still work? it's nice to have it both ways on PC

avatar image Macler Nov 17 '15 at 01:06 PM

Any ideas on changing just the button color and not the text color?

Cheers

avatar image channie Dec 08 '15 at 02:34 PM

use SetBackgroundColor for each button

avatar image Pumpkin Man Sep 25 '16 at 01:12 AM

Geez... I did exactly as suggested in the Blueprint of my Level, but all it does is allows the enter key to "Click" the target button... The arrow keys don't do anything at all. Does anyone have any suggestions on what might be wrong?

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

IF set keyboard focus DOESN'T WORK TRY ADDING A DELAY ! FIXED MY PROBLEM

more ▼

answered Apr 22 '16 at 04:30 PM

avatar image

Midnight640
46 8 10 14

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

I found this tutorial and work like charm for me ! hope it helps! link text

more ▼

answered Sep 18 '17 at 08:39 PM

avatar image

Manoloon
67 6 5

avatar image mightyenigma Nov 03 '17 at 08:02 AM

Yes that answered all my questions! There's a faster simpler one for non-textured styles here: https://www.youtube.com/watch?v=25mUUEdXMsU

I found for myself also that text input widgets don't need any blueprint checking to set focused style (they have a focused style already, along with the usual normal/hover/pressed styles), but buttons do need some extra logic to get them to change style on Focus/Blur since they don't have that.

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

To remove the dotted line you can create a class derived from "UGameViewportClient", then you put that class in your DefaultEngine.ini, below [/Script/Engine.Engine] you must add this line "GameViewportClientClassName=/Script/YourGame.YourGameViewportClient". In that class you must overwrite the function

 virtual void EnableShowCursor(bool canShowCursor);

to always return false.

With this, the dotted line should not appear

more ▼

answered Aug 23 '15 at 04:59 PM

avatar image

iscaru1988
211 7 13 20

avatar image cgrebeld Aug 24 '15 at 02:20 PM

Which version are you on? I can't find this method in 4.8.3

avatar image dgrieshofer Aug 27 '15 at 04:12 PM

Yea just checked git history and this function never existed in UGameViewportClient.h . Did not seem proper anyway as we still want to show the cursor itself but only hide that hideous dotted focus line.

avatar image artemavrin Apr 04 '16 at 09:25 AM

To hide the dotted line go to ProjectSettings - User Interface. Render Focus Rule set to never. That's all you need)

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

Sorry I was mistaken on the function to override, this is the good one:

 UCLASS()
 class UMyGameViewportClient : public UGameViewportClient
 {
     GENERATED_BODY()
 
 public:
 
     virtual TOptional<bool> QueryShowFocus(const EFocusCause InFocusCause) const override;
     
 }

.cpp code:

 TOptional<bool> UMyGameViewportClient::QueryShowFocus(const EFocusCause InFocusCause) const
 {
     return false;
 }

With this, the dotted line will no longer appear.

Tell me if this works for you.

more ▼

answered Aug 29 '15 at 03:08 PM

avatar image

iscaru1988
211 7 13 20

avatar image HavocX Dec 05 '15 at 06:40 PM

It worked for me, on 4.9.2.

Just make sure to restart the editor to apply the .ini changes.

avatar image keyle Apr 04 '16 at 07:56 AM

As of 4.8: Project Settings / User Interface / RenderFocusRule (Set To) Never

avatar image JasonSpangler Feb 14 '16 at 01:10 AM

I'd like to change the dotted line to something more visible (especially for 3D UMG Widgets in VR). Anyone know if it is possible to replace the dashed line with the hover behavior of widgets, or at least make the dashed line much more visible?

avatar image seandennis Jun 07 '16 at 04:39 AM

I've got a UMG 3d widget menu working but i'm struggling to get a dynamic Inventory system working with gamepad control. It only seems to interact with the last item in the inventory.

Menu system alt text

Dynamic Inventory alt text

Inventory gamepad control blueprint. alt text

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

@CodeSpartan Thank you so much for posting that solution! I had budgeted myself up to a day to get this working and with your help I was able to implement the feature in under 2 hours!

more ▼

answered Jun 24 '16 at 05:43 PM

avatar image

davethemadcat
1 1

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

Thx for your solustion .That works for me .

more ▼

answered Feb 10 '17 at 02:40 AM

avatar image

youthnick
175 1 5 7

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

Rama Plugin Solution

I made a Gamepad UMG plugin so you can use UMG with a gamepad.

Nick Darnell from Epic wrote the code and I made it into a plugin.

https://forums.unrealengine.com/showthread.php?86981-Gamepad-Friendly-UMG-Control-Cursor-with-Gamepad-Analog-Stick!-Easily-Click-Buttons!&p=550904&viewfull=1#post550904

Rama

more ▼

answered Jul 14 '17 at 04:29 PM

avatar image

Rama
10.6k 446 346 1088

(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