-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation for the MenuBar and the ContextMenu
- Loading branch information
Showing
3 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
docs/astro/src/content/docs/reference/window/contextmenu.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
<!-- Copyright © SixtyFPS GmbH <[email protected]> ; SPDX-License-Identifier: MIT --> | ||
title: Window | ||
description: Window element api. | ||
--- | ||
import SlintProperty from '/src/components/SlintProperty.astro'; | ||
|
||
`ContextMenu` is an invisible element that is used to show a context menu. | ||
|
||
The context menu is shown if the user right-clicks on the area covered by the `ContextMenu` element, | ||
or if the user presses the "Menu" key on their keyboard while a `FocusScope` within the `ContextMenu` is focused. | ||
It is also possible to show the context menu by calling the `show` function on the `ContextMenu` element. | ||
|
||
In addition to normal sub elements, the `ContextMenu` element can contain `MenuItem` elements. | ||
The MenuItem elements are defining the actual menu. | ||
|
||
## Function | ||
|
||
### show(Point) | ||
|
||
Call this function to programmatically show the context menu at the given position relative to the `ContextMenu` element. | ||
|
||
## `MenuItem` | ||
|
||
A `MenuItem` represents a single menu entry. It can be placed as a child of a `ContextMenu`, | ||
<Link type="MenuBar" />, or another `MenuItem`. | ||
|
||
### Properties of `MenuItem` | ||
|
||
#### title | ||
<SlintProperty propName="title" typeName="string" defaultValue='""'> | ||
The label of the entry within the menu. | ||
</SlintProperty> | ||
|
||
### Callbacks of `MenuItem` | ||
|
||
#### activated() | ||
|
||
Invoked when the menu entry is activated. | ||
This is only called if the menu entry doesn't have submenus | ||
|
||
## Example | ||
|
||
```slint | ||
export component Example { | ||
ContextMenu { | ||
MenuItem { | ||
title: "Copy"; | ||
activated => { debug("Copy"); } | ||
} | ||
MenuItem { | ||
title: "Paste"; | ||
activated => { debug("Paste"); } | ||
} | ||
MenuItem { | ||
title: "Cut"; | ||
activated => { debug("Cut"); } | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters