From 12a309c8a52ab6bc0498ce5230c91c0b5ffc99ee Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sat, 8 Oct 2022 08:02:02 +1100 Subject: [PATCH] Update menu docs --- website/docs/reference/menus.mdx | 37 +++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/website/docs/reference/menus.mdx b/website/docs/reference/menus.mdx index 1c2d3f5b7..05038b960 100644 --- a/website/docs/reference/menus.mdx +++ b/website/docs/reference/menus.mdx @@ -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