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"

Close UMG with key defined in Input mappings.

Hello,

I've search around a lot but couldn't find a real, up to date, answer so here I am.

I'm working on my inventory / menu system. I defined a key in Project Settings -> Input called "Toggle Inventory" and mapped to both spacebar and my controller start key.

I have the usual code in PlayerController to add the UMG to viewport, pause the game and switch to UI only input when the "Toggle Inventory" key is pressed:

alt text

The issue is... how do I go back ? I do know about the "KeyDown" event that can be overriden in UMGs, but you can't use the keys defined in Project Settings -> Input, you have to hard code the keys used..

I want my user to be able to customise that key later down the road, so hard coding is not an option.

A lot of old answers say to trick the system by leaving the InputMode at "Game and UI" and use the PlayerController to go back... that seems uggly.

Any up-to-date idea / tips ?

Thanks.

Product Version: UE 4.11
Tags:
more ▼

asked May 14 '16 at 01:42 AM in Blueprint Scripting

avatar image

Growiel
51 2 4 7

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

3 answers: sort voted first

In UMG Widgets there is a function called ListenForInputAction: https://docs.unrealengine.com/latest/INT/API/Runtime/UMG/Blueprint/UUserWidget/ListenForInputAction/index.html

This function will allow you to bind any predefined action, hope that helps!

EDIT: Here is a screenshot of an example usage, just replace the Action Name with the name of your input action: alt text

umg input.png (71.3 kB)
more ▼

answered May 14 '16 at 09:42 AM

avatar image

Fluppi393
457 35 33 54

avatar image Growiel May 14 '16 at 11:01 AM

Hi, thanks for that! I just look it up but I don't really know what an "action" is in this case. It wants a string, I tried feeding it my input name, but to no avail. Do you have any experience or examples in using this ?

avatar image Fluppi393 May 14 '16 at 11:16 AM

I edited my answer and added a screenshot.

avatar image Growiel May 14 '16 at 11:35 AM

Thanks again. That's what i tried but it didn't work. Is "Fire" defined under Project settings -> Input ? If yes, could it be an issue of focus on the Widget ? For completion sake, what key did you bound to Fire ?

avatar image Fluppi393 May 14 '16 at 12:23 PM

Yes Fire is an input action defined under Project Settings -> Input. If it doesn't work it might be because of the input mode, make sure you either use FInputModeGameAndUI or FInputModeUIOnly. Focus could be the issue as well, you could try to set the focus manually if the previous point didn't make it work.

avatar image Growiel May 14 '16 at 01:47 PM

Tried it again, everything's looking right but I can't make it work with "UI Only", "Game and UI" does work though. With UI only my string is never printed... Did you managed to make it worth with UIOnly ?

avatar image Fluppi393 May 14 '16 at 10:14 PM

It seems like input components from actors and UMG widgets are handled the same way, both won't receive input with InputModeUIOnly. So it seems like you do actually have to use GameAndUI mode for menus, the UIOnly mode seems to be really only for clicking buttons etc.

avatar image mdonge May 15 '16 at 12:08 AM

I tried many hours to do it, it would have been really easier ... But it doesn't work as shown before, for the moment you really have to use someting like the answer of this one :

https://answers.unrealengine.com/questions/119406/how-do-i-handle-action-mappings-on-an-umg-widget.html

avatar image Growiel May 15 '16 at 12:28 AM

Thanks to both of you, you confirmed what I thought. I really can't wrap my head around why it's so badly designed...

None of the workarounds are really working for me, as I also need to pause the game when the menu is open, and when the game is paused, no keys are sent even in GameAndUi mode...

Guess I'll look for an hacky way now that I know the clean one won't do it.

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

Yes, the idea of the other users is right.. you have to use the playercontroller to get the toggle inventory event to the umg.. its nasty. What might be possible is accessing the keybind information and use that knowledge to know what key press should trigger closing the umg.

A good place to start is probably looking at this code: https://forums.unrealengine.com/showthread.php?51449-Full-Project-Rama-s-UMG-Rebindable-Key-System-Rebind-keys-at-Runtime!

more ▼

answered May 14 '16 at 08:17 AM

avatar image

cageman
663 30 33 64

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

If you set to UIOnly, keyboard is disabled.

You have to set it in "InputAndUI" and disable input in your controller or character (I don't remember), this way the keyboard keeps sending keys, and the character won't move

more ▼

answered May 14 '16 at 09:45 AM

avatar image

mdonge
825 31 12 37

avatar image Fluppi393 May 14 '16 at 10:22 AM

If you use UIOnly input is disabled for actors, but the UI can still receive keyboard events! As the names suggest UIAndGame will allow actors AND UI to receive input and GameOnly will only allow actors to receive input.

avatar image mdonge May 14 '16 at 05:18 PM

In my project, this is not available because keys call function on server, So I had to set it as I said ... in UIOnly only mod only my mouse responds and the listen for input didn't work even when trying consume input or not ... I don't use add yaw input or anything else ...

(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