How to bind onclick event to UMG?

i know bind onclick event to button ,but there is an image in my Widget, how can i bind onclick event to the image?
thank you

Create a button then put your image ontop of it and set the visibility of your image to “Hit Test Invisible” so the image will never count as something clickable.
After that you just need to set your event to the button :slight_smile:

PS : Don’t forget to set the transparency of color and background color to 0 on your button so it doesn’t show.

Ad rXp noted, you can put a button and use the button hidden beneath the image or you can create a new widget to put your image in. In this new widget you can override all types of input events. Button will only give you click so if you need more create your own custom widget and pass through any events or functions you want.

谢谢! ~~
and i have an another question to ask you =.=
there is a person with a tennis racket(skeletalMeshActor) in hand on my level。 and now i want to dynamic change other tennis racket in UMG.
are there some node in bp? ==

thank you~~

So you have a picture of the tennis racket in the UMG ?
You just need to call SetBrush on your image widget :slight_smile:
But if you want to change the model of the racket in game you should not do that in UMG. You should have your controller call an event in your pawn to change it.

No your player controller BP should call and event (function) in your character BP. Level BP should only be used for Level specific code - things the Level needs to know. Therefore the level (or your UMG widget) doesn’t care if you “character” changes rackets. Only your character cares about that

oh~ i want to do the second thing ,that is to say i want to change the model of the racket. but i don’t understand your “You should have your controller call an event in your pawn to change it.” i should do that in level bp? +.+
could you Detailed explanation~~ thank you very much!

In your controller you use :
Get controlled pawn → Cast to [your pawn blueprint] → Call event [swap racket]

In the event :
Get [your racket component] → Set Mesh (your new racket)

I guess you are using only blueprint ?
This tutorial will help you : Setting Up a Character | Unreal Engine Documentation

The concept of character bp is not clear to me. my project only have level,actor and UMG. i don’t know how to build a playercontrol bp?

yes~i will learn it thank you~

In your hud you call an event that calls SetBrush on your image widget :slight_smile:
SetBrush will let you choose a new image to set.

=.= invite you answer pre question–“bind onclick event to button”. we can put image on top of button.but if i want to dynamic change the image on top of button.how to do that~~

Happy to help you ! No, from Switzerland ^^
Set this as answer then :slight_smile:

so nice~~ i spend two hours to solve the two problemlearn a lot ~~
thank you a lot

PS: i guess you come from Asia =.= right?

nicei come from china=.= thank you

now i meet another problemmay be you can give me some suggestion!
i am making a card game. there is a 3D person in level,and i will create a widget ,so it seems the 3D person is part of widget,that what i want. However the 3D person can not transparent from image of widget. now i want to image only to be background of 3D person. =.=need your ideal
~

you should create a new question about your followup question. Because it will be easier for people to help you and maybe people who have the same issue will be able to find the answer there :slight_smile:

I think this message will “unanswer” this answer xD

okeay~~~==