mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
Update menu docs
This commit is contained in:
parent
5fab671af3
commit
12a309c8a5
1 changed files with 24 additions and 13 deletions
|
|
@ -80,17 +80,28 @@ type MenuItem struct {
|
|||
}
|
||||
```
|
||||
|
||||
| Field | Type | Notes |
|
||||
| ----------- | ---------------------------------- | ------------------------------------------------------------- |
|
||||
| Label | string | The menu text |
|
||||
| Accelerator | [\*keys.Accelerator](#accelerator) | Key binding for this menu item |
|
||||
| Type | [Type](#type) | Type of MenuItem |
|
||||
| Disabled | bool | Disables the menu item |
|
||||
| Hidden | bool | Hides this menu item |
|
||||
| Checked | bool | Adds check to item (Checkbox & Radio types) |
|
||||
| SubMenu | [\*Menu](#menu) | Sets the submenu |
|
||||
| Click | [Callback](#callback) | Callback function when menu clicked |
|
||||
| Role | string | Defines a [role](#role) for this menu item. Mac only for now. |
|
||||
| Field | Type | Notes |
|
||||
| ----------- | ---------------------------------- |------------------------------------------------------------------------------------------|
|
||||
| Label | string | The menu text |
|
||||
| Accelerator | [\*keys.Accelerator](#accelerator) | Key binding for this menu item |
|
||||
| Type | [Type](#type) | Type of MenuItem |
|
||||
| Disabled | bool | Disables the menu item |
|
||||
| Hidden | bool | Hides this menu item |
|
||||
| Checked | bool | Adds check to item (Checkbox & Radio types). Updated automatically when item is clicked. |
|
||||
| SubMenu | [\*Menu](#menu) | Sets the submenu |
|
||||
| Click | [Callback](#callback) | Callback function when menu clicked |
|
||||
| Role | string | Defines a [role](#role) for this menu item. Mac only for now. |
|
||||
|
||||
### Keeping menu items in sync
|
||||
|
||||
A menuitem can be reused in multiple menus. This is useful for keeping menu items in sync. For example, if you have a
|
||||
"Quit" menu item, you can add it to both the Application menu and a system tray menu. When the user clicks the menu item,
|
||||
the callback will be called only once.
|
||||
|
||||
For checkbox and radio menu items, the state of the menu item will be kept in sync. For example, if you have a "Dark Mode"
|
||||
menu item in the Application menu and a system tray menu, when the user clicks the menu item in the Application menu, the
|
||||
state of the menu item in the system tray menu will also be updated. For radio menu items that are used in multiple places,
|
||||
clicking one will uncheck all others in all groups that the menu item is used in.
|
||||
|
||||
### Accelerator
|
||||
|
||||
|
|
@ -104,7 +115,7 @@ Example:
|
|||
myShortcut := keys.CmdOrCtrl("o")
|
||||
```
|
||||
|
||||
Keys are any single character on a keyboard with the exception of `+`, which is defined as `plus`.
|
||||
Keys are any single character on a keyboard except for `+`, which is defined as `plus`.
|
||||
Some keys cannot be represented as characters so there are a set of named characters that may be used:
|
||||
|
||||
| | | | |
|
||||
|
|
@ -219,7 +230,7 @@ type CallbackData struct {
|
|||
```
|
||||
|
||||
The function is given a `CallbackData` struct which indicates which menu item triggered the callback. This is useful when
|
||||
using radio groups that may share a callback.
|
||||
using radio groups that may share a callback. If the menuitem is a checkbox, the `Checked` property will be set to the new value of the checkbox.
|
||||
|
||||
### Role
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue