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"

[Closed] UMG Key Pressed

Hi all, i have a UMG menu and i want to close it when the user press the "p" key, but in the UMG there is no "p key pressed" event. How i can do that?

Another question: why,when i open the menu, i have to click twice for run the click event on the button? It's looks like that the umg has no focus.

Product Version: Not Selected
Tags:
more ▼

asked Mar 06 '15 at 03:29 PM in Blueprint Scripting

avatar image

Fanto88
318 23 15 28

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

The question has been closed Jul 09 '19 at 11:05 AM by Fanto88 for the following reason:

The question is answered, right answer was accepted


2 answers: sort voted first

To close a widget you have to remove it from the viewport (with the node called "Remove from Parent".

Just save the return value from "Create Widget" in a variable and use that to remove it when you press your key.

And for the focus. There are events to bring a widget into focus. Like "Set Focus UI" (something close to that. It's not quite the exact name). For this you will need again the widget reference.

more ▼

answered Mar 06 '15 at 04:50 PM

avatar image

Erasio
5.9k 291 86 293

avatar image AlexW88 Mar 06 '15 at 05:18 PM

Just add a Event for it in your Character, Level or Hud BP.

avatar image Fanto88 Mar 06 '15 at 05:26 PM

Ok, i resolved the focus problem with "SetInputMode_UIOnly" node. Now the problem is : How to detect that the player pressed the "P" key in the UMG?

avatar image Fanto88 Mar 06 '15 at 05:41 PM

I already have an event for the key and i can call it in the Level blueprint, but i can't call it during UMG blueprint. How to access to that event?

input.png (71 B)
menublueprint.png (267.0 kB)
umgmenu.png (37.5 kB)
avatar image Erasio Mar 06 '15 at 06:38 PM

You don't need to. For text you can set the keyboard focus to UMG but if you want to remove it use "Remove from Parent".

avatar image Fanto88 Mar 08 '15 at 10:24 AM

yes, i need it, because i want that the player could open the menu pressing the "p" key and that he could close it pressing again the "p" key but i don't know how to manage the "p pressed" on the UMG blueprint

avatar image AlphaSierra216 Mar 08 '15 at 10:45 AM

Does the "Set Input Mode Game and UI" allow the "p" event to fire?
It says that the if the input doesn't get handled by the widget then the Controller gets a chance to

avatar image Fanto88 Mar 08 '15 at 10:56 AM

The real problem was that when i create the UMG i put the "pause game" node, and it blocked the level blueprint script. Now i can close the menu with "p key" but how to stop the game run when the umg is open?

avatar image AlphaSierra216 Mar 08 '15 at 11:09 AM

Does the "Set Tickable when Paused" allow the level blueprint to keep running?

avatar image Fanto88 Mar 08 '15 at 11:11 AM

Ok i found how to control if the user press the p key during UMG, i need an event that could control that script, like "when a key is pressed" or something like that. Any suggestion how to do that?

avatar image AlphaSierra216 Mar 08 '15 at 11:27 AM

What do you mean by "Ok i found how to control if the user press the p key during UMG"?

avatar image Fanto88 Mar 08 '15 at 11:34 AM

Using that nodes i can control when the user press the "p key" in the umg, but i can't use event tick because it fires always, so when i press the "p key" for the first time the game open the menu ( i can see it) but the game close it at the same moment. So i need another event, but i can't find a solution

immagine.png (346.5 kB)
avatar image AlphaSierra216 Mar 08 '15 at 11:51 AM

If you use the flip flop node then each time the "p" key is pressed it will do the opposite of what it did last time

alt text

So the first time I press "p" it will print "Open" and the next time it will print "Close" then open then close etc...

Just make sure you only handle input with the "Was Input Key Just Pressed" node

thongs.jpg (100.1 kB)
avatar image Erasio Mar 08 '15 at 11:51 AM

May I ask you to listen to me?

From what I could gather you use the level blueprint for your logic. Not ideal but here's a solution exactly as I described it.

alt text

The variable widget is simply of the type "Widget". Please also notice that the checkbox "Execute when paused" inside of the "Event P" is enabled. First you create the widget, save it in a variable and then toggle between adding it to the view port and removing it from the same. A FlipFlop simply switches between A and B every time it's called.

I hope this clears things up.

Cheers.

widget.png (267.7 kB)
avatar image AlphaSierra216 Mar 08 '15 at 12:05 PM

Yes this ^^

I did not know that you could set inputs to be executed when paused Thanks!!

avatar image Khimari Sep 30 '15 at 07:48 PM

How does this thing work in 4.9? I spend 6 hours trying allmost everything possible yet I still can't close my pause menu by keyboard.

avatar image Erasio Sep 30 '15 at 10:18 PM

Pause menu?

Are you using the Unreal function to pause / freeze the game? Because if you do your input events to the controller will be frozen as well unless specified otherwise in the variable defaults.

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

Man, thank you. That's work fine! Just a little bug but i can resolve it, never noticed about the "execute when paused"! Thank you, sir!

more ▼

answered Mar 08 '15 at 12:05 PM

avatar image

Fanto88
318 23 15 28

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

Follow this question

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

Answers to this question