showContextMenu
Show the context menu.
import { showContextMenu } from "@app/ui"
showContextMenu(menu: Array<MenuItem>)
Arguments
menu: Array <MenuItem>
An array of menu items.
MenuItem: { title, onClick }
A menu item.
-
title:
string
The title of the menu item.
-
onClick:
ChatiumActions
The action to be performed when the menu item is clicked.
Examples
When the button is pressed, it shows a context menu with two items. Clicking on the first item displays a toast message "Hi!". Clicking on the second item opens the Google page.
import { showContextMenu, navigate, showToast } from '@app/ui'
app.screen('showMenu', async (ctx, req) => {
const menu = [{
title: 'Say "Hi!"',
onClick: showToast('Hi!')
},{
title: 'Navigate to Google',
onClick: navigate("https://google.com", {openInExternalApp: true})
}]
return (
<screen>
<button title="Menu" onClick={showContextMenu(menu)} />
</screen>
)
})