Help: How do you call a lick event in a widget

Hi

I have got it set up that when a player begins overlap, the mouse shows. Now I can call the button in the BP, but not sure of the node that registers the click event.

Cheers

hey, if its a button it has a built in OnClicked Event inside. I assume you are using UMG for that.

In the Designer Tab click your button, scroll down in the details Panel, you should see a Button “Add OnClickEvent” or something -> click it and do epic logic :wink:

Hi

Because there is many of the same widget doing different things, I need to create the event in the blueprint.

Kinda like this for text in a widget. :slight_smile:

Regards

Hey again,

i dunno what you mean with “doing different things” buttons will fire when you click on them. And they can fire a specific Event you want any button to fire.
Which Event a Button will fire can be set via an Interface or an Event Dispatcher.
Maybe, you can tell me an Example of what should happen when you click on a button you created.

best regards

Hi

When I meant by different things, is in one place it might give you health, in another stamina, another money, just by changing on thing in the BP.

2 bad examples.

Capture.JPG

hmm,

maybe you can create an Enum (Entries: Health,Stamina,Money,…)

Then your button will have this enum as a variable, you can set the variable on each creation of your Buttonwidget to one of those enums.

Now, when you click the button call you dispatcher event with the enum of that button as Input.

When the Event is fire you can switch on Enum and you can then tell what happens on the enum you got from your button.

Hi

The only thing is, I can not get button to fire :frowning:

oh if thats the case sorry i misunderstood you.

since its a 3D widget im gonna need to test it myself because i havnt until now.

brb :wink:

ah ok it worked.

So instead of doing the on click inside your widget blueprint. Go inside your 3D Blueprint with your widget as component.

Click the component you should see this:

you can add your OnClickevent here.

Lets say Print “Hello” when you click on it.

Unfortunately i just force deleted my Tutorial PlayerController class XD.

but it worked.

When you begin overlap or something,

set the Input to Game and UI or UI only and show the mouse, your button should now respond to your mouse.

tell me if this works for you

regards

One issue, is that There are multiple buttons on widget, how do I differentiate them?

That seems to, over entire widget.

the focusing is inherited to widgets children, so clicking a button will always fire this buttons click event.

But the problem may be the experimental stage of 3D widgets.

One workaround would be add each button as a component itself. Then adde the onClick event.

Im not sure if 3D Widgets already fire inner logic.
OnClick inside the Component is for the Component itself i think. So differentiate on this way is not that easy.

I would like to know if the Buttons onclick is fired.

Test that out:

Inside your Widget Blueprint add the OnClick event to a button with Print String “Hello”.

no onclick in your 3D Widget Blueprint

your mouse should be able to focus each button and click one right?

Ok its working quite well, no need for you to test :wink:

ok next thing would be:

add the enum i mentioned in your Widgets BP as variable

then inside your Construction Script of your 3D BP set the enums for your widgets button reference.

GetUserWidgetOBject -> Cast to your WidgetBP-> set output as variable.

Now get each button from that new variable and for each button set the desired enum you want this button to be.

I added this:

4acdd456ec52e2f89ae3520f4c2568c2ed5692b0.jpeg

No luck.

I think I will have to go over some inventory tuts to debug it.

I like the thought of separate widgets as a work around.

And learn what a enum is

i make pictures for you :slight_smile:

hmmm i cant add more pics… seems to be restricted or something… i cant show you the ouput right now, but i promise they are printing the debug lines

Edit: what i do in On Event Begin play (setup input mode and cursor) will be placed in your Begin Overlap or something