Update menu docs

This commit is contained in:
Lea Anthony 2022-10-08 08:02:02 +11:00
commit 12a309c8a5
No known key found for this signature in database
GPG key ID: 33DAF7BB90A58405

View file

@ -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