Button on widget pressed to have action on Level Blueprint

Hi all,
I have seen a similar question here but not quite like this.
I have some buttons on my widget and I have my game logic in my Level Blueprint. In development I used A and D keys for certain actions, now I need to muster my buttons for them.
I want the following: a button is pressed on my widget, anothers is clicked same on my widget. I want them to influence my Level Blueprint.
Also, the game is for pc atm, but will set the project to mobile. These UI buttons, do they adapt by themselves or will I have to do something differently?
Thanks in advance.

To connect your button you will need to use an event dispatcher.

In your button widget, create an event dispatcher and call it like so:

98759-buttonwidget.png

Then in your level blueprint, you create the widget and bind whatever functionality you would like.

1 Like

As @anonymous_user_8b4c4b4d explained how to get the widgets interact with level Blueprints i would like to add this to complete the answer,


the onpress is for mobiles ,touch screens and
onclick is for PC

while developing you can select these options for mobile


and while testing in PIE make sure of these

Use OnPressed instead of OnClicked.

And it seems to work, thank you both.
Now, To the mobile setup: ATM I’m in desktop/console. I know how to change it to mobile and then restart it (did it once at early stage). after that do I have to make some magic, or all the buttons work as they should? (once I set the preferences to mobile input)?

just one more thing. it acknowledges the button clicked only when I release the button. How to get to fire off as soon as I click it? Is it the work of the on clicked event? So the on clicked means fire off as soon as released, and only once?

yeah, like a minute after asking I realized that myself. was just testing it to avoid this looping effect or what: when I hold it down it acts like I’m pressing it repeatedly very quickly. but it doesn’t. thanks again.