-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply suggestions from code review Co-authored-by: Simon Hausmann <[email protected]>
- Loading branch information
Showing
2 changed files
with
42 additions
and
24 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,19 +1,18 @@ | ||
--- | ||
<!-- Copyright © SixtyFPS GmbH <[email protected]> ; SPDX-License-Identifier: MIT --> | ||
title: Window | ||
description: Window element api. | ||
title: ContextMenu | ||
description: ContextMenu element api. | ||
--- | ||
import SlintProperty from '/src/components/SlintProperty.astro'; | ||
import Link from '/src/components/Link.astro'; | ||
|
||
`ContextMenu` is an invisible element that is used to show a context menu. | ||
Use the non-visual `ContextMenu` element to declare 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. | ||
or if the user presses the "Menu" key on their keyboard while a `FocusScope` within the `ContextMenu` has focus. | ||
Call the `show()` function on the `ContextMenu` element to programmatically show the context menu. | ||
|
||
In addition to normal sub elements, the `ContextMenu` element can contain `MenuItem` elements. | ||
The MenuItem elements are defining the actual menu. | ||
Define the structure of the menu by placing `MenuItem` elements into the `ContextMenu`. | ||
|
||
## Function | ||
|
||
|
@@ -38,24 +37,27 @@ The label of the entry within the menu. | |
#### activated() | ||
|
||
Invoked when the menu entry is activated. | ||
This is only called if the menu entry doesn't have submenus | ||
|
||
:::note{Note} | ||
This is only called if the menu entry doesn't have submenus. | ||
::: | ||
|
||
## Example | ||
|
||
```slint | ||
export component Example { | ||
ContextMenu { | ||
MenuItem { | ||
title: "Copy"; | ||
activated => { debug("Copy"); } | ||
title: @tr("Cut"); | ||
activated => { debug("Cut"); } | ||
} | ||
MenuItem { | ||
title: "Paste"; | ||
activated => { debug("Paste"); } | ||
title: @tr("Copy"); | ||
activated => { debug("Copy"); } | ||
} | ||
MenuItem { | ||
title: "Cut"; | ||
activated => { debug("Cut"); } | ||
title: @tr("Paste"); | ||
activated => { debug("Paste"); } | ||
} | ||
} | ||
} | ||
|
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