Button Release Action in UMG

I am very sorry if this has already been requested but I have searched extensively and have not found a request. In the UMG editor (widget blueprint), when you create a button you can add an on clicked event. What I am requesting is a on release event. There is a work around for this if you are using mouse and keyboard. But there is simply no way to do it if you are using touch (for mobile). What i want to do is set a variable when the button is held down, and upon release reset the variable to it’s default value. Right now it stays at it’s pressed value, even on release. This should be such a simple thing but it is made difficult by the smallest things :mad:. I’ve tried everything, please help :(! Otherwise, is there some sort of work around for mobile?

Thanks,

Instead of using a button, just use an image as its own UserWidget. Override the OnTouchStarted and OnTouchEnded functions to do what you want.

Then replace the buttons on your first UserWidget with these new UserWidgets with override functionality and make sure their visibilities are set to “Visible” so they can receive events.

Thank you so much!!! :smiley: I’ve been trying to find a solution for so long. This one worked!
Once again thank you!

Thanks,

I’ve been using UMG since it first appeared and I just learned about this three weeks ago. :stuck_out_tongue:

Still though this should be added to buttons.

You always typically want to act on a release event rather than a press event. This is how all buttons work in UI normally. If a user is randomly moving their mouse and accidentally pushes down, the release event will happen outside the button as the user moves the mouse, and an accidental mouse press will be avoided.

I agree, there should be events for press, release, click and double-click. However if you just want one for one of your buttons, you can set the button-click trigger event in the button details (except double-click).

button.png

So you can make your button react on release instead or press and release.

The 4.8 button contains OnPressed/OnReleased.

Awesome news! Is my memory failing me that buttons used to have these events but have since lost them?

Nope, didn’t have them until 4.8. They were added back in like Jan/Dec? but because of the way things got reshuffled for 4.7/GDC, it didn’t come in an official build until now.

It’s possible I was using a Github build at that time. Thanks for the information, Nick :slight_smile:

Hello. Is there a way button doesn’t trigger twice [on click] and when releasing from [on hold] ?
I understand I can make button

but (if I’m not super wrong) whatever I pick in some way I trigger twice.
Example: I have a button for horn. If I press once I just horn. If I hold the button, I’m horning as long as I hold. So any way I set it up, I play two different sounds (@once) at the press or at release :confused: