-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ItemList can not scroll by dragging on the ItemList #13235
Comments
Similar to #8151, though not a duplicate. |
I am using this script to allow dragging on an ItemList. Use at your own risk: extends ItemList
export(float) var drag_threshold = 5
onready var touch_enabled = OS.has_touchscreen_ui_hint()
onready var v_scroll = get_v_scroll()
var dragging = false
var pressed = false
# must be _input, as _gui_input has bugs, with no touch.pressed = false events
# see: https://github.com/godotengine/godot/issues/16761
func _input(event):
if not visible:
return
if not touch_enabled:
return
if event is InputEventScreenDrag:
accept_event()
if event.speed == Vector2():
# we're on a device and speed is broken
# see: https://github.com/godotengine/godot/issues/3623
event.speed = event.relative
if abs(event.speed.y) >= drag_threshold:
# scroll the list
dragging = true
v_scroll.value -= event.relative.y
return
if event is InputEventScreenTouch:
if event.index == 0:
accept_event()
if dragging && event.pressed == false:
# prints("end drag")
dragging = false
pressed = false
else:
if event.pressed && pressed == false:
# prints("touch start")
pressed = true
# TODO: prevent select highlight
elif !event.pressed && pressed == true:
# prints("touch end and accept")
pressed = false
var ev = InputEventAction.new()
ev.action = "ui_accept"
ev.pressed = true
Input.parse_input_event(ev) |
Same with ScrollContainer, it works in Tree, see in FileDialog |
I use this script which is quite simple and should fill most use cases: extends ItemList
onready var Scroller: VScrollBar = self.get_v_scroll()
func _ready():
self.connect("gui_input", self, "_on_gui_input")
func _on_gui_input(event: InputEvent):
if event is InputEventScreenDrag:
self.Scroller.value -= event.relative.y I then have a "Go" (confirmation) button which appears whenever any item in the list is selected. That way I can scroll as much as I want without closing the window. |
Closing in favor of a feature proposal godotengine/godot-proposals#2429 |
Operating system or device, Godot version, GPU Model and driver (if graphics related):
godot 2.1
device iOS, Android
Issue description:
On touch screen device,
the ItemList can only scrolled by dragging the scroll bar.
When touch on the ItemList itself and drag, it can not scroll.
This is not the same as the list on touch screen.
Steps to reproduce:
Link to minimal example project:
The text was updated successfully, but these errors were encountered: