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.
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
#
Whether browser context menu disabling is currently requested.
This flag is managed by this service instance:
- initialized to False;
- set to True after disable();
- set to False after enable().
Note
On non-web platforms, browser context menu control is not applicable, but this property still reflects the last requested state.
Methods#
disable
async
#
Disable the browser's context menu.
By default, when the app starts, the browser's context menu is already enabled.
enable
async
#
Enable the browser's context menu.
By default, when the app starts, the browser's context menu is already enabled.