Download

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

Hi All

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

Narg

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:

3a9dd25720e614d690e705163be18c052dbe681b.jpeg

Regards

Narg

Hey again,

i dunno what you mean with “doing different things” all 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

Capture.JPG

Narg

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:

Narg

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:

8827154c986daaad0a719625e632f82583d603d7.jpeg

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.

Narh

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.

Narg

And learn what a enum is

lol

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