Long press buttons in UMG

I am using UMG buttons for controls, and I need to set up single button press and 2-second press too. Is there any way to make this kind of controls with UMG?

In your button widget blueprint you can setup a flow like this to create that functionality.

Note! “On Pressed Time” is a user created float variable that you need to create by yourself.

1 Like

I updated the flow with “Greater or Equal to” instead of “Greater than”…

Hello everybody i have a question that blueprint can be connecte with the Arduino, i mean is posible to connect a botton electronics the out analogic controller the actor via serial? how can i do it? anyone knows? i new about this UE4 and i want to do someting like that , thanks !

This solution is not going to work correctly, sadly. The get game time in seconds function is returning how long the game has currently been running and will restart at 0 when the game is re-launched. I was hopeful that function would have been a solution to this specific problem regarding getting the elapsed time of an event.

Because it’s not a full solution. It’s just a example how to detect a button press that’s longer then 2 second.
If you want to make it work then disable “Is Focusable” in the button options.

292534-isfocusable.png

1 Like

Works good!

1 Like

Do not forget turn off IS FOCUSABLE

thank you

Just found this thread while looking for the same thing. The Game Time is a nice approach, but is only checks after releasing the button if it has been pressed long enough. So when keeping it pressed, nothing would happen.

There are other solutions with a looping timer adding fractions of the second but I just found another quick solution for this:

The delay will fire after one second, but only if the button is still pressed. If the button gets released earlier, the branch will prevent it from firing.