Fix wheel scrolling
This commit is contained in:
parent
5c5b35f0d1
commit
376896da1e
1 changed files with 8 additions and 0 deletions
|
@ -31,10 +31,17 @@ extends SuiBaseClass
|
||||||
## Useful when editing the contents of a SuiScroller node, but may cause visual chaos.
|
## Useful when editing the contents of a SuiScroller node, but may cause visual chaos.
|
||||||
@export var editor_clip_content: bool = true
|
@export var editor_clip_content: bool = true
|
||||||
|
|
||||||
|
## Internal, don't modify.
|
||||||
|
var mouse_hovering: bool = false
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
super()
|
super()
|
||||||
if !in_editor(): logger = core.logger.get_instance("SUI/src/SuiScroller.gd", self)
|
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:
|
func update_element() -> void:
|
||||||
# Clip contents
|
# Clip contents
|
||||||
if in_editor() and !editor_clip_content: clip_contents = false
|
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
|
# Credit: https://forum.godotengine.org/t/how-do-i-get-input-from-the-mouse-wheel/27979/2
|
||||||
func _input(event: InputEvent):
|
func _input(event: InputEvent):
|
||||||
|
if !mouse_hovering: return
|
||||||
if event is InputEventMouseButton:
|
if event is InputEventMouseButton:
|
||||||
if event.is_pressed():
|
if event.is_pressed():
|
||||||
match(event.button_index):
|
match(event.button_index):
|
||||||
|
|
Loading…
Reference in a new issue