Skip to main content

DragTargetEvent coordinate fields deprecated

note

This guide is accurate as of Flet 0.85.0. Later releases might add new APIs or additional migration paths.

The breaking changes and deprecations index lists the guides created for each release.

Summary

Flet 0.85.0 deprecated DragTargetEvent.x, DragTargetEvent.y, and DragTargetEvent.offset.

Use DragTargetEvent.local_position for target-relative coordinates, or DragTargetEvent.global_position for page-level coordinates.

Context

The old x, y, and offset fields did not make their coordinate space explicit. The new position fields separate target-relative coordinates from global coordinates, which makes drag and drop code easier to read and less ambiguous.

Migration guide

Code before migration:

def on_accept(event: ft.DragTargetEvent):
target_x = event.x
target_y = event.y
target_position = event.offset

Code after migration:

def on_accept(event: ft.DragTargetEvent):
target_x = event.local_position.x
target_y = event.local_position.y
target_position = event.local_position

If your code needs page-level coordinates instead, use event.global_position.x, event.global_position.y, or event.global_position.

Timeline

  • Deprecated in: 0.85.0
  • Removal in: 0.88.0

References