Skip to content
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

feat: custom ReorderableListView drag handle listeners #5051

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Mar 8, 2025

Test Code

import flet as ft


def main(page: ft.Page):
    page.title = "ReorderableListView Demo"

    # the primary color is the color of the reorder handle
    page.theme = page.dark_theme = ft.Theme(
        color_scheme=ft.ColorScheme(primary=ft.Colors.BLUE)
    )
    get_color = (
        lambda i: ft.Colors.ERROR if i % 2 == 0 else ft.Colors.ON_ERROR_CONTAINER
    )

    page.add(
        ft.ReorderableListView(
            expand=True,
            build_controls_on_demand=False,
            on_reorder=lambda e: print(f"Reordered from {e.old_index} to {e.new_index}"),
            show_default_drag_handles=True,
            controls=[
                ft.ReorderableDraggable(
                    index=i,
                    content=ft.ListTile(
                        title=ft.Text(f"Item {i}", color=ft.Colors.BLACK),
                        leading=ft.Icon(ft.Icons.CHECK, color=ft.Colors.RED),
                        bgcolor=get_color(i),
                    ),
                )
                for i in range(10)
            ],
        )
    )


ft.app(main)

Summary by Sourcery

Adds the ability to customize drag handles in the ReorderableListView control by introducing the show_default_drag_handles and mouse_cursor properties.

New Features:

  • Adds the ability to hide default drag handles in ReorderableListView.
  • Adds the ability to customize the mouse cursor when hovering over drag handles in ReorderableListView.

Summary by Sourcery

Adds the ability to customize drag handles in the ReorderableListView control by introducing the show_default_drag_handles and mouse_cursor properties.

New Features:

  • Adds the ability to hide default drag handles in ReorderableListView.
  • Adds the ability to customize the mouse cursor when hovering over drag handles in ReorderableListView.

@ndonkoHenri ndonkoHenri added this to the Flet v0.28.0 milestone Mar 12, 2025
@ndonkoHenri ndonkoHenri added controls feature request Suggestion/Request for additional feature labels Mar 12, 2025
@ndonkoHenri ndonkoHenri marked this pull request as ready for review March 17, 2025 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
controls feature request Suggestion/Request for additional feature
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

1 participant