Bind event in main widget without reference to child widget with the event


New to BPs and UE.

I have a main widget that has several child widgets.




WB_Grid is a variable to WB_Main. The WB_Item child widgets are added in at runtime to WB_Grid. I would like to notify WB_Main that a double click happened on WB_Item so WB_Main can display a window with data. But WB_Main does not have an array where it keeps track of WB_Item. WB_Main has no WB_Item variable either. Of course it has reference to WB_Grid and WB_Item is a child of that. WB_Grid also has no variable references to WB_Item.

It seams there is no way to directly bind WB_Main to this event dispatched by WB_Item. The event does not show when I right click in the BP editor. Unless I am missing something.

What is best practice for such case? I guess I could create an array in WB_Main and keep track of items and bind to their event as they populate the array and unbind as they get removed. But that feels wrong to me. I could also have WB_Item find WB_Main as parent of a parent through a bunch of loops, and then call a function in it, but that sounds even worse. WB_Item should not know about WB_Main as a principle. But maybe I am wrong. Maybe I just need a beer.

Thank you! Sorry I am new to UE.

Look at this, please.

Thank you for the reply and for the code! Looping until you find the widget you need is a workaround. I might have to do something like that. But I was after a built in solution.

Your link did lead me to UMG Viewmodel here:

Which might be the way to go, I just had no time to dive in and I also found no examples yet.