Reference to blueprint from widget

I have Blueprint, in which I move the camera to a different position.
This is created through a custom event.
This part works correctly.

In addition, I have a Widget in which there is a button to move this camera, in the same widget file I have an object reference variable to call a function from the blueprint file (another file)

The problem is that I cannot select “Default Value” to point to the blueprint file.
Because in Outliner I have this blueprint as main and in it child widget and it is in the widget that there is no option for selecting the file.

The first picture shows what I mean.
At the same time, this is the aforementioned blueprint and under it is a widget.
Blueprint communicates with another file without any problem

Here we have a widget enabled, where I can not select the same option.

Due to which when I click on the widget button I get an error
“Blueprint Runtime Error: “Accessed None trying to read property As BP_Widget_MainMenu. Node: Camera Move Level Select Graph: EventGraph Function: Execute Ubergraph WBP Main Menu Blueprint: WBP_MainMenu”

Pic from editor, where is “NONE” as object reference
I can’t edit it

That’s pretty normal. A behaviour like this is best (there are many ways, though) achieved through a delegate. You do not need this part:

image

Instead:

The above translates to - whenever a button is clicked, execute a custom event in this actor. You can instruct the BP Camera Level what to do.


Note, we can take it further and make it better by implementnig a custom Event Dispatcher in the widget - this way each button can send unique data. And we can execute an event in another actor (BP_CameraLevel) directly:

  • we receive a notification in the BP Camera Level

  • in the widget, each button click dispatches unique data:

  • in the main menu actor that hosts the widget component:

In short: whenever a widget button is clicked, the BP Camera Level actor receives a notification (and data).