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: expose events (on_double_tap, on_pan_start) in WindowDragArea #5043

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

Conversation

ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Mar 7, 2025

Resolves #5018

Test Code

import flet as ft


def main(page: ft.Page):
    page.vertical_alignment = ft.MainAxisAlignment.CENTER
    page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
    page.spacing = 20

    page.add(
        ft.WindowDragArea(
            content=ft.Container(
                content=ft.Text("maximizable=True"),
                alignment=ft.alignment.center,
                bgcolor=ft.Colors.RED,
                width=300,
                height=200,
            ),
            maximizable=True,
            on_double_tap=lambda e: print("W1 on_double_tap"),
            on_pan_start=lambda e: print("W1 on_pan_start"),
        ),
        ft.WindowDragArea(
            content=ft.Container(
                content=ft.Text("maximizable=False"),
                alignment=ft.alignment.center,
                bgcolor=ft.Colors.BLUE,
                width=300,
                height=200,
            ),
            maximizable=False,
            on_pan_start=lambda e: print("W2 on_pan_start"),
        ),
    )


ft.app(target=main)

Summary by Sourcery

The pull request introduces new events (on_double_tap, on_pan_start) to the WindowDragArea control, allowing developers to handle double taps and pan start gestures within the drag area. It also modifies the control to inherit from GestureDetector instead of ConstrainedControl.

New Features:

  • Expose on_double_tap event to handle double taps within the drag area.
  • Expose on_pan_start event to handle pan start gestures within the drag area.
  • Make the window maximizable on double tap if maximizable is set to True.
  • Call start_dragging on the window to initiate window dragging on pan start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose WindowDragArea events
1 participant