Can't pan/drag my camera if my cursor is hovering over a button

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Deazy

Hello, I have a problem: When I use my panning/dragging the camera around function it works fine. But if my cursor is hovering over any button in that scene it no longer works.

I have tried moving the nodes around in my scene but it doesn’t help. I don’t know what else should I try. Please help.

Here is the code for the dragging/panning:

func _unhandled_input(event: InputEvent) -> void:

    if event is InputEventMouseMotion:
	    if event.button_mask == BUTTON_MASK_MIDDLE:
		    position -= event.relative * zoom

you already answered.
mouse works in blank areas of the screen. When it hovers over another node, the function comes to that node.

sorry i use translation
English is not my native language.

ramazan | 2022-09-19 21:23

:bust_in_silhouette: Reply From: exuin

“unhandled” input only detects input that is not being handled by other nodes. The buttons are handling the input. Use _input instead.

Thank you. In the meantime I made a workaround using Area2D and CollisionPolygon2D. I tried changing _unhandled_input to _input tho and it works as well. It is better than the workaround I did so I’ll change it.

Deazy | 2022-09-20 13:53