InputMap.action_add_event for MOUSE_BUTTON_WHEEL_UP / DOWN?

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

Here is my function:

func define_keybindings():

# directional keys
var _left = InputEventKey.new()
_left.set_keycode(KEY_A)
InputMap.action_add_event("ui_left", _left)
var _right = InputEventKey.new()
_right.set_keycode(KEY_D)
InputMap.action_add_event("ui_right", _right)
var _forward = InputEventKey.new()
_forward.set_keycode(KEY_W)
InputMap.action_add_event("ui_up", _forward)
var _back = InputEventKey.new()
_back.set_keycode(KEY_S)
InputMap.action_add_event("ui_down", _back)

# mouse wheel
var _zoom_in = InputEventKey.new()
_zoom_in.set_keycode(MOUSE_BUTTON_WHEEL_UP)
InputMap.action_add_event("ui_page_up", _zoom_in)
var _zoom_out = InputEventKey.new()
_zoom_out.set_keycode(MOUSE_BUTTON_WHEEL_DOWN)
InputMap.action_add_event("ui_page_down", _zoom_out)

It works perfectly for KEY_n but fails for MOUSE_BUTTON_WHEEL_UP / DOWN

Any insights would be appreciated, thank you.

:bust_in_silhouette: Reply From: Wakatta

Most likely due to those not being InputEventKeys

# mouse wheel
var _zoom_in = InputEventMouseButton.new()
_zoom_in.set_button_index(MOUSE_BUTTON_WHEEL_UP)
InputMap.action_add_event("ui_page_up", _zoom_in)

var _zoom_out = InputEventMouseButton.new()
_zoom_out.set_button_index(MOUSE_BUTTON_WHEEL_DOWN)
InputMap.action_add_event("ui_page_down", _zoom_out)