Download

Widgets: how manage a lot of buttons?

Hi all,

I will have an “inventory” widget with a lot of buttons, 50 buttons+,
instead of manuallly place 50 event “On Clicked (BTN_01)…”
can i have 1 event general evnet (on click button), and then ask , if is BTN_01 , do this, if BTN_02 do this…?

I am little lost,
maybe i can use Event dispatchers? how?
maybe i can place custom widget inside the inventory and , let the child-widget talk to the parent? how?
other options?

thank you

You can do much better than this. Wrap each button in a widget - this gives you a fully configurable widget. Create a dispatcher that broadcasts data from the button. So you can do this, for example:

Button with an enumerator and a dispatcher:

07159e75c1c06034c8dd4263091b90be0bba0312.jpeg
https://forums.unrealengine.com/core/image/gif;base64

Flagging any variable as Instance Editable, allows you to modify it on the parent:

8d2aa652df9b4d993e23b376d66d87df1b09d972.jpeg

And then the parent can do this:

04fbd15b76c09faa540d2498fd72f9824e657b72.jpeg

Whenever a button is clicked, the event at the bottom gets executed. This can be leveraged in many ways. No need for more wires.

And you can do this from outside of the parent widget; you can actually use a dispatcher to evoke events in another actor, here in the LB but it can be anything, of course:

Above, any click from a button will trigger an event in this particular actor, pushing in enumeration data defined in the second screenshot. Binding / unbinding can be done dynamically so you can hook events like this on the fly and without worrying about those actors getting destroyed.

1000 Thanks man @Everynone
I really appreciate it,
So much stuff to learn, i will try all this,
Thanks again