Calling a widget (as a layout) blueprint custom event from player controller

How do I properly cast a widget
blueprint custom event inside a widget

Casting is not a form of communication. Think of casting as of conversion. You take one data type and attempt to treat it as if it was another.

If you have a widget reference of the correct type already, you do not need to cast, for example:

Above, calling a custom event of a widget nested in another widget.


Where, in which blueprint, do you create the widget the PC is trying to access?

Well it is a widget inside a layout, and I’m creating the layout inside the PC, but I’m unable to cast from this specific widget… I have already succeeded to make it work but through an interface I’m posting the my own answer now, but I’m still interested to some other proper way ^^

Okay I have finally got this to work…

  • Created an Interface and attached it to ControllerBP
  • Added 2 boolean outputs (ZoomIn & ZoomOut) to the Interface
  • Created those very same booleans on ControllerBP and setted them to the input buttons keys
  • On the widget created a get player controller node and called that very same Interface (message) reference from it

Then I was able to finally get that info to the widget and made it to work on the Event Tick with some Branches and well placed good ol’ DoOnces !

Was really hoping to do this with my way but I was unable to reach it event through event dispachers… But it’s working now anyway, if you’re reading this, please don’t abstain to comment if there’s a better approach !

How do I properly cast a widget blueprint custom event inside a widget that is inside another widget (As a layout) ? seems that I can’t set this up…

I have a minimap, and there are 2 working buttons for zooming in and out, I’m setting up the numpad’s keys + and - in player controller to then call the widget custom events to do the thing… Tried to cast the widget inside the widget layout failing the cast, tried all kind of casting to everything and nothing seems to work

How do I properly do this? Which is the best approach for this?

Mmmh, yes the problem is that the widgets are not the same type, they are different widgets ! That’s why I need to cast them, I understand now the difference of call and cast my friend thanks for that !

Is the other / nested widget added dynamically?

In my example above, they’re also different widgets.

No, it is not, it’s like this

So what exactly is stopping you from doing what I’m doing.

Get Example Layout 5 → Get Minimap → call Custom Event

In my case:

306701-annotation-2020-07-09-214217.jpg

YEAS !

I was trying to cast directly the minimap but I needed to cast to Example Layout 5 first face palm xD

That was much appreciated my man, will mark your answer ^^ thank you !! ■■■■ it, those things happens when you have given too much hours on the same problem…

Yeas, I have done this now that I’m able again to cast that widget properly

It was a d-umb mistake, happens when you have been thinking over this too long, needed another to make me realize, thank you again

By the way, are you making a boat or ship game? wCrewHealth This must be interesting !

My answer to this comment is waiting moderation and I don’t know why xD

But, I was trying to cast directly the minimap and I needed to cast to Example Layout 5 first !

That was much appreciated my man, thank you !!

If you create the widget in the PC and store the reference of the correct type (right click the Return Value pin of the Create Widget node and Promote To Variable to automate this process), there is no need to cast.

But perhaps you’re storing just a generic Widget reference to swap different layouts, each being another widget. In that case, you’d need to cast, of course. Or use the interface.

My answer to this comment is waiting
moderation and I don’t know why xD

Happens, when you (s)hit a blacklisted word, for example.

It’s working like a charm

306713-setwidbl.jpg

306714-zoominput.jpg