Hey! I was wondering if it was possible to check if the mouse is clicking a certain PNG image in a widget. I got this PNG tree image for test purposes:
When you say it prints the coordinates even when you don’t press the tree, are you still pressing the transparent area around the tree inside the green box?
An easy way to do this would be to use a button instead of an image. You can set the button to draw as an image instead of a rectangle, and give it display logic for when it is not hovered, hovered, and pressed.
If you want to program it with click logic, you can do that in the event graph for the button. A single button can do multiple things if you so choose.
Thank you! That fixes my problem. But do you know of any way to detect if the button is being hovered when the mouse is down? The function itself works just fine when I simply hover it, but if the mouse is down, for example, in a drag & drop situation, it does not work anymore.
You are very welcome! Proceeding from here you have a couple of options.
If you are just looking to be able to click and hold a button, you could make use of a couple of other event triggers in the button blueprint; On Pressed, On Released, and Event Tick. You can set a boolean when the button is pressed which then allows events in event tick to fire, and is set to false when the button is released. Very simply, something like this.
In your case though, if you want the UI elements themselves to be draggable, you should look into this documentation about creating draggable UI elements.