Mouse wheel detection not working in OS X

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

I’ve been trying to detect the scroll wheel to perform a zoom in my normal dev env in macox and it is not working. Meanwhile, I tried the exact same thing in windows and it works.
I’ve tried using Actions, but in my last attempt I did the most simple project possible. A a sprite, a camera2d (set to current) with the following code:

func _input(event):
	if event is InputEventMouseButton:
		if event.is_pressed():
			if event.button_index == BUTTON_WHEEL_UP:
				print("wheel up")
			if event.button_index == BUTTON_WHEEL_DOWN:
				print("wheel down")

Is there anything special I need to do for mac?
PS: The mouse wheel works fine in the scroll container.

:bust_in_silhouette: Reply From: JasperC

I’ve been having the same problem. Did you ever find a solution?

Yes, use InputEventPanGesture instead of InputEventMouseButton. See example above (I’ve answered my own question).

erebrus | 2022-07-09 05:21

:bust_in_silhouette: Reply From: erebrus

The key is using InputEventPanGesture instead, e.g.

if event is InputEventPanGesture:
if !Input.is_action_pressed(“drag_on”):
if focus_object==null:;