I have been trying to detect mouse clicks on a node. The node is an Area2D with a sprite and CollisionArea2D as children.
I have followed the answer from this question: https://godotengine.org/qa/22606/how-ive-handled-area2d-mouse-click-not-question, but I cannot get the input_event function to run on mouse clicks, only on mouse motion in and out of the collision area.
What should I do to correctly detect mouse clicks on the node?
# Called when the node is added to the scene for the first time.
func _on_book_input_event(viewport, event, shape_idx):
print("Something happened! ", event)
** Debug Process Started **
OpenGL ES 3.0 Renderer: Intel(R) HD Graphics 620
Something happened! [InputEventMouseMotion:1117]
Something happened! [InputEventMouseMotion:1168]
Something happened! [InputEventMouseMotion:1225]
Something happened! [InputEventMouseMotion:1276]
Something happened! [InputEventMouseMotion:1387]
Something happened! [InputEventMouseMotion:1390]
Something happened! [InputEventMouseMotion:1393]
Something happened! [InputEventMouseMotion:1429]
** Debug Process Stopped **
Here I moved the mouse onto and off of the node a few times, and clicked on the node each time. Only the movement of the mouse triggered the function to run.
I know that I can use onmouseentered and onmouse_exited in combination with the general input function to do what I want, but I would prefer to get the simpler solution working, or at least understand why it is not.