How to communicate between two widgets

Hey everyone,

I’m trying to get two widgets to talk to each other by using an OnClicked event.

Basically what I want to do is,
*Click a button in widget A
*Set a bool in widget A to true
*Click a button in Widget B to call the Widget A bool to create another widget.

My problem is, I keep getting accessed none errors, I’ve tried every method I know. But I haven’t had any luck. I’ve been able to communicate between a BP_Actor and a Widget before using Custom Events, but it won’t work when I try it with two widgets. I’m also not able to set a value for the Widget A variable in Widget B like the documentation said to do.

Any help would be greatly appreciated.

Here are some screenshots:
Widget A: Screenshot - c07c683a6a51a61d5d4f7e1f985e9813 - Gyazo
Widget B: Screenshot - ed0c6d3b97f9504e6ada756a86b15c6c - Gyazo

Cheers,
Entro

One easy way to do this is make one widget create the other widget. So for example Button A widget does a “create widget” for Button B. Then Button A adds itself to a variable in Button B and at the same time Button A adds a variable to Button B. You can easily do this off an Event Construct.

1 Like

I’m sorry, but that went a bit over my head. Can you provide a screenshot or two to demonstrate that?

Kinda depends what you’ve attached these widgets to, but let’s say the Parent here is your player controller (easiest example). One thing that should work is to go back in your controller blueprint and find wherever you’ve created those widgets in the first place before adding them to the viewport. The create nodes should have a blue output pins on them - right click each and Promote to Variable. Give them names that make sense to you, like “WidgetA” and “WidgetB” in your case. That will save a reference to each that will be important later when you try to communicate between them.

So in Widget A, you can get the owner - which will likely be a generic controller - then Cast To your special type of controller - and then the reference to Widget B can be pulled off that cast node. You can then change a variable or toss an event into B as you wish. If you are doing this in some sort of pawn or character, you might need an extra step to get the controller - then get that thing’s “controlled pawn” - cast that to your BP_Actor class and look up your widget references there.

Note that things are cleaner here in 4.12 - if you’re still in 4.11 or earlier there’s even one more step. Once you have the widget reference to Widget B, you used to have to pull off that and get the user widget object, then Cast To whatever widget type that guy is, and -then- you can get into its variables and events. Way confusing and always seems to take more nodes than it should. If you’re blindly trying to find the magic node that does all that, you’d never find it on your own.

Here you go. I hope this helps.

This is in the Widget A Graph.

I think I understand what you mean. I’m going to have to try this tomorrow and send some screenshots to see if I understand it right.

Ohhh, okay. That makes sense. Thank you so much for the screenshots. I’m gonna try this out tomorrow as well.

I decided to give it a try now and it worked! Thanks for the input, I really appreciate it.

I also tried this and it worked, but the scripts seem a bit cleaner (at least for me) with 1l2Hawk’s solution. I really appreciate both of your inputs though, you really got me through a bind.

I have read the thread and tried what has been mentioned here. But I failed.

I am trying to create a bridge of communication between two widgets, but everything has failed thus far. Simply because I Fail to recreate what has been taught to me, or understand the logic behind them.

I have created a string array holding a list of names of players inside. I want another widget to have an access to this array list, but I have run out of options. If only there was someone who could explain this in some other way than what has been already explained above.