I’m trying to call a custom event i created inside my first widget, inside my second widget. The custom event makes changes to my first widget, but the code i wrote for it doesn’t give the right result, although it should?
widget 1 containing custom event
widget 2 containing the button, when clicked calls custom event:
sorry if i’m not understanding straight away what you mean, I am a beginner in UMG still
what do you mean? can you explain further?
No they are not, I am trying to calling the custom event ‘Show Image’ from ‘Text Photos Widget’ that does not own it by ‘creating widget’ to get a reference to ‘Lilas Chat Widget’, this does not work.
Hmm so you want to create LilaChatWidget from ContactsWidget, and then you want to access it from TextPhotosWidget ?
Right now you are creating two LilaChatWidget :
one from ContactsWidget, which is added to viewport but ShowImage is never called on it
another one from TextPhotosWidget, where you call ShowImage but it is not added to viewport
So instead of creating a second widget, you need to use the existing one.
The simplest way to retrieve it would be to use node “Get All Widgets Of Class”.
thank you for getting back to me. I apologize for the late reply, this seemed to have worked I am now able to call the function correctly. I have one more issue that I think might be linked to what you were saying.
I am setting a variable that belongs to a widget called ‘Expanded Image’ from within my ‘Text Photos Widget’. Again i’m creating this widget then getting access to the variable and setting it that way.
On my ‘Show Image’ function, ‘Expanded Image’ Widget is added as a child to ‘Lila Chat Widget’ I do know I should use ‘get all widgets of class’ then I used ‘For each loop with break’ but I dont think this is right, the widget is not being added and nothing happens.
You are calling ShowImage before creating the ExpandedImage widget, so in ShowImage the call to GetAllWidgetsOfClass finds nothing. You probably want to create the widget and set its SelectedImage variable, and THEN call ShowImage to add the widget into your box.
Instead of using GetAllWidgetsOfClass, you could add a parameter to your ShowImage function, and pass the created ExpandedImage widget through as parameter. This would be much proper.