Skip to content

ContextMenuArea

Use the non-visual ContextMenuArea element to declare an area where the user can show a context menu.

The context menu is shown if the user right-clicks on the area covered by the ContextMenuArea element, or if the user presses the “Menu” key on their keyboard while a FocusScope within the ContextMenuArea has focus. On Android, the menu is shown with a long press. Call the show() function on the ContextMenuArea element to programmatically show the context menu.

One of the children of the ContextMenuArea must be a Menu element, which defines the menu to be shown. There can be at most one Menu child, all other children must be of a different type and will be shown as regular visual children. Define the structure of the menu by placing MenuItem or Menu elements inside that Menu.

export component Example {
ContextMenuArea {
Menu {
MenuItem {
title: @tr("Cut");
activated => { debug("Cut"); }
}
MenuItem {
title: @tr("Copy");
activated => { debug("Copy"); }
}
MenuItem {
title: @tr("Paste");
activated => { debug("Paste"); }
}
MenuSeparator {}
Menu {
title: @tr("Find");
MenuItem {
title: @tr("Find Next");
}
MenuItem {
title: @tr("Find Previous");
}
}
}
}
}
slint

Call this function to programmatically show the context menu at the given position relative to the ContextMenuArea element.

Close the context menu if it’s currently open.

booldefault: true

When disabled, the Menu is not showing.

Place the Menu element in a MenuBar, a ContextMenuArea, or within another Menu. Use MenuItem children of individual menu items, Menu children to create sub-menus, and MenuSeparator to create separators.

stringdefault: ""

This is the label of the menu as written in the menu bar or in the parent menu.

booldefault: true

When disabled, the Menu can be selected but not activated.

imagedefault: the empty image

The icon shown next to the title when in a parent menu.

A MenuItem represents a single menu entry. It must be a child of a Menu element.

stringdefault: ""

The title shown for this menu item.

booldefault: true

When disabled, the MenuItem can be selected but not activated.

booldefault: false

When true, the MenuItem can be checked. The value of the checked property is toggled when the user activates the menu item.

keysdefault: @keys()

The keyboard shortcut for this MenuItem.

This property can only be set in a MenuItem that is part of a MenuBar.

bool(in-out)default: false

When true, a checkmark will be shown next to the title of the MenuItem.

imagedefault: the empty image

The icon shown next to the title.

enum MenuItemRoledefault: none

The platform role of this MenuItem. Use it to place translated “About”, “Settings”, and “Quit” items in the macOS application menu.

This property can only be set in a MenuItem that is part of a MenuBar.

MenuItemRole

This enum describes the platform role of a MenuItem in a MenuBar.

On macOS, the native menu bar moves items with a role into the application menu. On other platforms, about, preferences, and quit items stay where they’re declared, and items with the other roles are hidden.

  • none: The item has no special role and stays where it’s declared.
  • about: The item opens the application’s “About” information.
  • preferences: The item opens the application’s settings. The shortcut defaults to Command+, on macOS.
  • quit: The item quits the application. The shortcut defaults to Command+Q on macOS.
  • services: The item is the system’s “Services” sub-menu on macOS. activated isn’t invoked and shortcut is ignored.
  • hide: The item hides the application on macOS. activated isn’t invoked and shortcut is ignored.
  • hide-others: The item hides all other applications on macOS. activated isn’t invoked and shortcut is ignored.
  • show-all: The item shows all hidden applications on macOS. activated isn’t invoked and shortcut is ignored.

Invoked when the menu entry is activated.

A MenuSeparator represents a separator in a menu. It cannot have children, and doesn’t have properties or callbacks. MenuSeparator at the beginning or end of a menu will not be visible. Consecutive MenuSeparators will be merged into one.


© 2026 SixtyFPS GmbH