SpyrexDE / SmoothScroll

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

Drag input within scroll containers not possible #24

Closed SpyrexDE closed 1 year ago

SpyrexDE commented 1 year ago

In contrast to the native scroll container, the Smoothscroll container does not allow for passing drag input to its children:

https://github.com/SpyrexDE/SmoothScroll/assets/57133330/6b3f20c4-b088-43b4-9a73-30527d9cb302

HaroldLever commented 1 year ago

I think it might be OK by setting the mouse filter of rich text label to STOP. BTW, I suggest delete "remove_mouse_filter" in _ready() function, giving back the right to let users control it.

SpyrexDE commented 1 year ago

@HaroldLever You are right and it would be nice to allow the user to choose if the input should stop on the element or be passed to the scroll container. However, I chose this workaround because all Controls' mouse filters are "stop" by default. So when someone would just drag their label into the scroll container they won't be able to scroll using touch controls unless they figure out they have to set the right mouse filters. Do you have any idea on how to set the default filter for all children controls to "pass" while still allowing some to be specifically "stop?"

HaroldLever commented 1 year ago

I do have an idea.

  1. Use @tool
  2. Add get_tree().node_added.connect(node_added) in _ready()
  3. Add if Engine.is_editor_hint(): return at first line of _process()
  4. Add a new function func node_added(node): if node is Control and Engine.is_editor_hint(): if is_ancestor_of(node): node.mouse_filter = Control.MOUSE_FILTER_PASS

It would set PASS the default filter in EDITOR mode once a new child added to the container. You can delete "and Engine.is_editor_hint()" in node_added() if you want it work in GAME mode. (Not recommended)

SpyrexDE commented 1 year ago

@HaroldLever That's a great idea, I will implement it soon. Thank you!