diff --git a/sui/src/SuiScroller.gd b/sui/src/SuiScroller.gd index 8c786c4..1c8d340 100644 --- a/sui/src/SuiScroller.gd +++ b/sui/src/SuiScroller.gd @@ -31,10 +31,17 @@ extends SuiBaseClass ## Useful when editing the contents of a SuiScroller node, but may cause visual chaos. @export var editor_clip_content: bool = true +## Internal, don't modify. +var mouse_hovering: bool = false + func _ready() -> void: super() if !in_editor(): logger = core.logger.get_instance("SUI/src/SuiScroller.gd", self) +func _process(delta): + mouse_hovering = Rect2(Vector2(), size).has_point(get_local_mouse_position()) and !Rect2($HScrollBar.position, $HScrollBar.size).has_point(get_local_mouse_position()) and !Rect2($VScrollBar.position, $VScrollBar.size).has_point(get_local_mouse_position()) + super(delta) + func update_element() -> void: # Clip contents if in_editor() and !editor_clip_content: clip_contents = false @@ -185,6 +192,7 @@ func _scroll(direction: SuiTypes.ScrollDirection) -> void: # Credit: https://forum.godotengine.org/t/how-do-i-get-input-from-the-mouse-wheel/27979/2 func _input(event: InputEvent): + if !mouse_hovering: return if event is InputEventMouseButton: if event.is_pressed(): match(event.button_index):