Calling UMG Events from SkookumScript

I just want to fire an event inside a Widget blueprint. I can access the widget class from the SkookumScript. What I have tried is calling on clicked event of a button inside the constructor of the Widget.

event

ss

Currently it does nothing. I am sure my syntax is wrong. If you could give me some reference on how to do it, it would help me a lot. Thanks.

Help me understand what you’re trying to do here.

Are you:

  1. Trying to call some :sk: code from inside the widget blueprint?
  2. Trying to call a widget blueprint function from some other :sk: code?
  3. Something else?

The code you showed:
@button_local.@on_clicked is just referencing a local @on_clicked variable but won’t result in calling anything. OnClicked is a delegate and there currently isn’t a way to call the delegate directly. But you can call functions.

Since I think you’re attempting to do #2, I’d recommend making a BP function in your widget blueprint, for example SelectButton. And make whatever calls you need to in the SelectButton BP function. Then in your local :sk: constructor just call @button_local.select_button.

Also your constructor named !constructor is something I have not seen before, as constructors are typically just named ! in :sk:. One last thing to be aware of, widget’s can get constructed outside of an actual game world existing, so if you ever get a crash inside a constructor because some object doesn’t exist, remember me mentioning this.

1 Like

Yep I am trying to do #2. Thank you for this great explanation. I’ll try this. :slight_smile:

1 Like

No problem, let me know how it turns out for you. I’m currently spec’ing out some tutorial content and have added a UMG example to my list that covers #1 and #2.

1 Like

So I got it working by creating a Custom Event inside the Blueprint Widget and connecting it to the flow of blueprint nodes and then calling that Custom Event from SkookumScript. :slight_smile:

1 Like