目录

Menu Overview

A menu is a pop-up window that allows users to perform specific actions. It typically appears when users right-click, long-press, or touch an item.

When to Use

API Use Case
Menu control (Menu) Used to bind actions to specified components, such as displaying operation options when an icon is long-pressed.
Global menu independent of UI components (openMenu) Used to provide operation options in scenarios where UI components cannot be directly accessed, for example, in event callbacks.

Constraints

Lifecycle

The normal sequence is aboutToAppear > onWillAppear > onAppear > onDidAppear > aboutToDisappear > onWillDisappear > onDisappear > onDidDisappear.

Name Type Description
aboutToAppear () => void Callback invoked when the menu is about to appear.
onAppear () => void Callback invoked after the menu appears.
aboutToDisappear () => void Callback invoked when the menu is about to disappear.
onDisappear () => void Callback invoked after the menu disappears.
onWillAppear Callback<void>

Event callback before the menu display animation starts.

Note: aboutToAppear is triggered during initialization, while onWillAppear is triggered before the animation starts. onWillAppear is executed after aboutToAppear.

onDidAppear Callback<void>

Event callback after the menu pops up.

Note:

1. When you tap the button quickly, the menu pops up and disappears rapidly. In this case, onWillDisappear may take effect before onDidAppear.

2. If the menu is closed before the entrance animation completes, this callback is not triggered.

3. onAppear and onDidAppear share the same trigger timing, and onDidAppear takes effect after onAppear.

onWillDisappear Callback<void>

Event callback before the menu exit animation starts.

Note:

1. When you tap the button quickly, the menu pops up and disappears rapidly. In this case, onWillDisappear may take effect before onDidAppear.

2. aboutToDisappear and onWillDisappear share the same trigger timing, and onWillDisappear takes effect after aboutToDisappear.

onDidDisappear Callback<void>

Event callback after the menu disappears.

Note: onDisappear and onDidDisappear share the same trigger timing, and onDidDisappear takes effect after onDisappear.