I don’t know if I misunderstood how this should work. I have some widgets and a base widget that has all the other widgets inside. Now I have buttons events in my widgets I want to forward to the base widget.
I make an Event Dispatcher and call that in the sub widgets from the button click events. In the base widgets I want to bind to the dispatcher using the UI:
But the resulting node never triggers. Does this not automatically bind to the event dispatcher? If not, why does this even exist? Or how is this supposed to be used?
The event is called like this:
Thanks and cheers!
Does this not automatically bind to
the event dispatcher?
tl;dr: no, it has to be done manually - somewhat - depends on how you structure things and who talks to whom
You do need to register the event. For a simple OnClick, you do not need to create an additional event dispatcher in the child, it already exists.
In the base widget:
Hold, Move, and Orbit are children user widgets, each with a (BTN) button. You do not need to implement any extra calls in the child for this either.
Now, every time the button is clicked in the child, it will fire the bound event in the parent widget.
You do want to create an additional dispatcher if you want to send some data back - like a color of the button, for example. The button’s onClicked sends just the execution, but no data.
edit: However, any Event Dispatchers declared in the Child User Widget become automagically available in the parent:
…the exact same way as the button’s events are available in the parent that is housing it:
The difference here is that a user widget is a wrapper for whatever resides inside, so you need to access the elements inside this wrapper first - see the first pic - I need to get to the embedded button first to get to its event.
Child Dispatches information:
Parent catches it:
No binding is necessary here as there’s a direct child / parent relationship here.
If you wanted just the button’s onClick, then you’d need to bind:
If you leave the dispatcher Call in the pic 1 as is, this Hello will trigger twice. Once through the button’s onClick and then through the Dispatcher call.
Thanks for the answer.
Yeah they become available, but when I call the event in the child widget like in my picture above, why does it not trigger in the parent widget when I add it with the plus? What else do I need to do?
Well, but that’s exactly how I did this.
Thank you for your commitment, I will take a look at it tomorrow, but it seems there is something else fishy about my setup if it’s supposed to work like this.
Alright I DO NOT know what was wrong.
I tried this again today and looked over everything and there was nothing pointing me to any mistake I made. Then I tried this in a seperate project and it worked. Then I migrated these two widgets in my main project and there it worked too. Then I switched back to the widgets I actually wanted to use, and suddenly they worked too. What in the world… ??
Anyways, thank you for your help!
Haha, there’s only one worse feeling - when stuff works fine but you know it should not!