bug: Solitaire Demo code uses wrong delta
Duplicate Check
- [x] I have searched the opened issues and there are no duplicates
Describe the bug
Flet: 0.82.2
Flutter: 3.41.4
Pyodide: 0.27.2
In the "Getting Started" Solitaire tutorial, when implementing the drag function, the online instructions and github example code use e.delta_y and e.delta_x to update the control position. However in the version of Flet that I'm running, I had to update the code to use e.local_delta.y and e.local_delta.x to work properly. I was also able to confirm that the DragUpdateEvent does not have delta_y or delta_x properties defined on the object
Code sample
Code
import flet as ft
# Use of GestureDetector with on_pan_update event for dragging card
# Absolute positioning of controls within stack
def main(page: ft.Page):
def drag(e: ft.DragUpdateEvent):
e.control.top = max(0, e.control.top + e.delta_y)
e.control.left = max(0, e.control.left + e.delta_x)
e.control.update()
card = ft.GestureDetector(
mouse_cursor=ft.MouseCursor.MOVE,
drag_interval=5,
on_pan_update=drag,
left=0,
top=0,
content=ft.Container(bgcolor=ft.Colors.GREEN, width=70, height=100),
)
page.add(ft.Stack(controls=[card], width=1000, height=500))
ft.run(main)
To reproduce
- Run the code
- Attempt to drag the card
- See
AttributeError: 'DragUpdateEvent' object has no attribute 'delta_y'traceback in console
Expected behavior
The card should reposition when the user clicks and drags on the element.
Screenshots / Videos
Captures
[Upload media here]
Operating System
Windows
Operating system details
WSL2
Flet version
0.82.2
Regression
No, it isn't
Suggestions
Updating the tutorial and example code to use e.local_delta.x and e.local_delta.y
Logs
Logs
Unhandled error in 'on_pan_update' handler
Traceback (most recent call last):
File "/home/xxx/flet-play/lib/python3.13/site-packages/flet/messaging/session.py", line 334, in dispatch_event
await control._trigger_event(event_name, event_data)
File "/home/xxx/flet-play/lib/python3.13/site-packages/flet/controls/base_control.py", line 440, in _trigger_event
event_handler(e)
~~~~~~~~~~~~~^^^
File "/home/xxx/flet-play/flet_play/sample.py", line 8, in drag
e.control.top = max(0, e.control.top + e.delta_y)
^^^^^^^^^
AttributeError: 'DragUpdateEvent' object has no attribute 'delta_y'
Additional details
No response
Fixed in Flet 0.83.1 by #6344. The Solitaire tutorial and drag examples now use local_delta.x and local_delta.y instead of the removed delta_x and delta_y.