showModalMenuAsync()
Displays a context/dropdown menu with the provided list of items.
showModalMenuAsync(
config: ModalMenuOptions | ((opts: ModalMenuOptions) => void),
ref?: {
lastRenderOutput?: RenderContext.Output;
},
): Promise<unknown>;
Summary
This method displays a modal menu, using the specified options (or options that are set in a configuration function). The menu is positioned near a particular UI element, an instance of UIElement, e.g. a button that was clicked by the user.
The value property of the chosen menu item, if any, is returned asynchronously. If the menu was dismissed, the returned promise is resolved to undefined.
Note
Use fmt to translate item text if necessary; this method doesn’t localize strings by default.
Parameters
- config — An instance of ModalMenuOptions, including a list of menu items; or a callback function to set options for the menu to be displayed
- ref — The related UI element
Return value
A promise that resolves to the selected item value, if any
Errors
This method throws an error if the modal menu controller can’t be initialized (i.e. there’s no modal factory or menu builder).
Related
class AppContext
A singleton class that represents the global application state.
