Widget: How can 2 Widgets, each made for their own, communicate, when they are in the same "parent"?

Hello everyone, Roni the Newbi here.

As you can see in the first picture i have 2 special widget as children in my “Hbox” , named “W_Skillimage” and “W_LVUP”. In “W_LVUP” i want to access “W_Skillimage”, as seen in the second picture.

I know casting rules for the most part, how do i get the owner/parent of “W_LVUP” so that i can cast to that “HBox” /“W_Skillsslotactive1”(“HBox” is part of “W_Skillsslotactive1”) and then get “W_Skillimage”?

Extra Info: im creating 100 of these beforehand and in game things happen. So automating it seems to make sense.

In general you don’t. Instead you’d make a widget that has the W_LVUP and W_Skillimage contained in it and anything that’s meant to be an interaction between them is handled by that widget.

1 Like

In addition to what @MagForceSeven is saying: There are four ways for UI widgets to communicate.

The first is to use event emitters on each of the widgets, and then wire those up when you create the widgets.

The second is to use delegates on each of the widgets, and “pull” values whenever you need them – this is what the “Bind” mechanism that’s built into the editor does.

The third is to use an “owning” widget that knows how to read value out of one and write to the other.

The fourth is to drive the widgets from some central state store, and make them read from / update that state. And if two widgets display different aspects of the same state, they will then update together, without knowing about each other.

Each of these options work well for different use cases, so without knowing exactly what it is you want to do, I don’t know which would be the most convenient for you – maybe try all of them and see which one works?


Thanks both of you, MagForceSeven and jwatte for your quick and easy to understand help.
I resolved my problem in another way:

Get all of the LVUPs and see, which one is equal to the current in use.

jwatte, I will have to look a lot more at event emitters and delegates, thanks for showing me a new way.