Skip to content

WindowDragArea

It mimics the behavior (drag, move, maximize, restore) of a native OS window title bar on the content control.

Inherits: LayoutControl

Properties

  • content(Control) –

    The content of this drag area.

  • maximizable(bool) –

    Whether double-clicking on the WindowDragArea should maximize/maximize the app's

Events

Examples#

No frame window#

import flet as ft


def main(page: ft.Page):
    page.window.title_bar_hidden = True
    page.window.title_bar_buttons_hidden = True

    async def handle_window_close(e: ft.Event[ft.IconButton]):
        await page.window.close()

    page.add(
        ft.Row(
            controls=[
                ft.WindowDragArea(
                    expand=True,
                    content=ft.Container(
                        bgcolor=ft.Colors.AMBER_300,
                        padding=10,
                        content=ft.Text(
                            "Drag this area to move, maximize and "
                            "restore application window."
                        ),
                    ),
                ),
                ft.IconButton(ft.Icons.CLOSE, on_click=handle_window_close),
            ]
        )
    )


ft.run(main)

no-frame-window

Properties#

content #

content: Control

The content of this drag area.

Must be visible.

Raises:

maximizable #

maximizable: bool = True

Whether double-clicking on the WindowDragArea should maximize/maximize the app's window.

Events#

on_double_tap #

on_double_tap: (
    EventHandler[WindowEvent[WindowDragArea]] | None
) = None

Called when the WindowDragArea is double-tapped and maximizable=True.

Info

When a double-tap event is fired, the type property of the event handler argument can only be one of the following: WindowEventType.MAXIMIZE, WindowEventType.UNMAXIMIZE.

on_drag_end #

on_drag_end: (
    EventHandler[DragEndEvent[WindowDragArea]] | None
) = None

Called when a pointer that was previously in contact with the screen and moving/dragging is no longer in contact with the screen.

on_drag_start #

on_drag_start: (
    EventHandler[DragStartEvent[WindowDragArea]] | None
) = None

Called when a pointer has contacted the screen and has begun to move/drag.