How to send parameters with UButton OnClicked?

Hello guys,

So at the moment I made 2 levels and I want to use the same function for both the buttons. In the function I need to know which button is clicked, so I can open the right level. I can’t find anything on the internet. Can someone else help me with this?

Code at the moment:

225553-vragenue42.png

1 Like

Hey there, use this.

Thanks for your reaction.
I already tried that and I had the same name with both buttons.

1 Like

Do I need to make a slate widget for this?

1 Like

Instead of sending the name on the delegate, send the button itself, that way you can compare the instance itself.

1 Like

Hey, sorry for my late reaction. I already sorted it out with the link that you wrote. I didn’t knew there was a class to create a customized button.

1 Like

Maybe try this

FOnClicked::CreateStatic(&YOURFUNCTION, Parameter1, Parameter2)

or

FOnClicked::CreateSP(this, &YOURFUNCTION, Parameter1, Parameter2)
1 Like

I meet the same question recently and my solution is :
create a single widget class and a blueprint widget for the “buttons”
add these buttons to a parent panel such as Wrapbox UniformGridPanel or sth that can contain multi children dynamically, then in C++ class ,write this line
‘this->GetParent()->GetChildIndex(this)’
then you can get the index of the dynamically created buttons ,use the unique index to continue your codes
but be cautions,it seems like the chileindex only be gotten correctly after PreConstruct and Construct, in Tick.
Poor English but hope it can help!

1 Like