How can I disable Vertical/Horizontal Scroll Bar's scroll wheel functionality?

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

I’m trying to implement a screen magnifier option as an accessibility implementation. However, the scroll wheel functionality of the vertical/horizontal scroll bar interferes with this (it should not trigger so the zoom function can use the scroll wheel for ease of access). Is there a way to turn this functionality off or override the function?

I’m using a ScrollboxContainer to store the elements. Do I need to make a custom GUI class for this?

:bust_in_silhouette: Reply From: dewcked

Given node tree


click ScrollContainer. In inspector dock, go to Mouse > Filter and set Ignore. For me, it worked. But when you wheel inside the VScroller, it still scrolls the screen.

To prevent this, add script below to the ScrollContainer

var _v_scroll: VScrollBar

func _ready() -> void:
    _v_scroll = get_node("_v_scroll")

func _input(event: InputEvent) -> void:
    if event is InputEventMouseButton and (event.button_index == BUTTON_WHEEL_DOWN || event.button_index == BUTTON_WHEEL_UP):

when you scroll, it disables the mouse input. When you not, it enables the mouse input.

This actually doesn’t fully work, you need to also change the mouse filter with the container. (The scrolling also happens on the container as well as the scroll bar). But once I did that, it worked! Thanks.

punishedfelix | 2021-11-26 14:05