Skip to content

BrowserContextMenu

Controls the browser's context menu on the web platform.

The context menu is the menu that appears on right clicking or selecting text in the browser, for example.

On web, by default, the browser's context menu is enabled and Flet's context menus are hidden.

On all non-web platforms, this does nothing.

Inherits: Service

Properties

Methods

  • disable

    Disable the browser's context menu.

  • enable

    Enable the browser's context menu.

Examples#

#
# Run this example as a web app using the command:
#
#     flet run --web basic.py
#


import flet as ft


async def main(page: ft.Page):
    bcm = ft.BrowserContextMenu()

    async def disable_context_menu():
        await bcm.disable()

    async def enable_context_menu():
        await bcm.enable()

    page.add(
        ft.Column(
            [
                ft.Button(
                    "Disable browser context menu", on_click=disable_context_menu
                ),
                ft.Button("Enable browser context menu", on_click=enable_context_menu),
            ],
        )
    )


ft.run(main)

Properties#

disabled property #

disabled

Methods#

disable async #

disable()

Disable the browser's context menu.

By default, when the app starts, the browser's context menu is already enabled.

enable async #

enable()

Enable the browser's context menu.

By default, when the app starts, the browser's context menu is already enabled.