SpyrexDE / SmoothScroll

Addon for the Godot Game Engine that adds a SmoothScrollContainer.
https://spyrexde.github.io/SmoothScroll/
MIT License
132 stars 10 forks source link

Dragging scroll bar presents weird behavior #61

Closed HaroldLever closed 2 months ago

HaroldLever commented 2 months ago

Godot version

4.2.1 stable

Smooth scroll container version

d1a7891

Description

https://github.com/SpyrexDE/SmoothScroll/assets/80692930/a5bd9ff1-fb52-48fc-a08b-52a27a8bc9ac

https://github.com/SpyrexDE/SmoothScroll/assets/80692930/f97fbfee-ef33-40b2-b06f-31ae0223d680

Then I tried to set scroll bars' 'focus_mode' to All, but something weird occurred.

Steps to reproduce

Check properties on rich text label. Add these few lines in update_text() might help you check any_scroll_bar_dragged().

func update_text(ssc:SmoothScrollContainer):
    while true:
        await get_tree().process_frame
        new_text = ""
        for propertyInfo in property_list:
            var propertyName : String = propertyInfo.name
            var propertyValue = ssc.call("get", propertyName)
            var propertyType = propertyInfo.usage
            new_text += "[color=green]%s:[/color] %s\n" % [propertyName, propertyValue] if propertyType == 4096 else "[color=yellow]%s:[/color] %s\n" % [propertyName, propertyValue]
            # new lines
            if propertyName == "v_scrollbar_dragging":
                new_text += "[color=lightblue]%s:[/color] %s\n" % ["any_scroll_bar_dragged()", ssc.any_scroll_bar_dragged()]
SpyrexDE commented 2 months ago

It's probably better to use the scroll bar's gui_input event to determine if they are being dragged instead of relying on their focus_mode. The scroll behavior when scrollbars are focused is in fact weird but I can't think of a use case where a user would like to make the scroll bars focusable.