I’m wondering if it’s possible to call the Widget ‘onbuttonclick’ event inside of an Actor BluePrint.
I’ve created a Widget BluePrint, with some buttons. But I want to script the functionality in an actor blueprint, for these buttons. I managed to create the following set-up:
You can see that I call a custom event ‘Item1Clicked’, that requests a Brush variable ‘image preview’. Now I want to set this brush variable onto the actor blueprint, so that I can easily duplicate the functionality and modify it in the world outliner.
I can get this working by calling a keypress event like so:
The problem is, I don’t want to call this event when pressing “M”, or any other key. I only want to call this when I’m clicking on that widget button. But I don’t know how…
I hope I provided enough info,
If you want to call the event directly from the HUD, you should create a button that you need to press inside the HUD, and create the event called by the button click.
Thanks for your reply. I’m trying to call the OnClicked event outside the of the UMG widget, not inside. Thanks for taking the time though ;).
Calling OnClicked directly is not the right way to do it. Instead, call the Item1Clicked event from outside.
I don’t understand what the problem is here. If you don’t want to call Item1Clicked from the outside, just don’t call it from the outside?
In general, tying “clicked the first button” to some action is too much coupling; it’s better to have an event for “I want to preview thing X” as that’s more descriptive of what you actually want to do.
It’s probably not the right way to do it, but let me explain more clearly what I’m trying to accomplish.
I want to create multiple shops, selling and showing different items. But, I would like all shops to work with the same widget blueprint. Therefore, I want the widget blueprint to use the actor’s variables and use that to display and sell the items in that shop widget.
So here is what I think I have to do. I need to create the visual HUD in the widget blueprint, but then script the functionality in an actor, so that I can duplicate that actor and simply change the item variables but have it function instantly. I know I can ‘hardcode’ the items in the widget blueprint, but that wouldn’t allow me to duplicate the actors without duplicating that shop widget with it.
I hope that sheds some more light on what I was trying to accomplish. I’ll just script everything in the HUD widget for now, as I don’t see another way that fits my skill set.
This is what you need, really useful when you know how.
Hey Raiden, this should do it for me. Thanks a bunch!