You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With Kando 3.0, the IPC API has been updated to version 2. Previously, there were `select-item`, `hover-item`, and `cancel-menu` messages. In version 2, these have been replaced by a single `menu-interaction` message that provides more detailed information about the user's actions.
|`show-menu`| Client | Request to show a custom menu. Pass the menu structure via the `menu` parameter as JSON. **The format of the menu is the same as the one used in the `menus.json` file.** See [Menu Configuration](/config-files/#menu-item-descriptions) for more details. |
108
-
|`select-item`| Server | The selected item is passed via the `path` and `target` parameters. These describe its position in the menu tree and the type of item which was selected. See below for an example. |
109
-
|`hover-item`| Server | Use this to get notified when the user hovers over a menu item. The same parameters are used as in `select-item`. |
110
-
|`cancel-menu`| Server | Triggered when user closed the menu without a selection. |
111
-
|`error`| Server | An error occurred. Inspect the `reason` and `description` properties for more details. |
111
+
|`show-menu`| Client | Request to show a custom menu. Pass the menu structure via the `menu` parameter as JSON. **The format of the menu is the same as the one used in the `menus.json` file.** See [Menu Configuration](/config-files/#menu-item-descriptions) for more details. |
112
+
|`menu-interaction`| Server | The selected item is passed via the `path` parameter. The type of interaction via the `interaction` parameter. See below for details. |
113
+
|`error`| Server | An error occurred. Inspect the `reason` and `description` properties for more details. |
112
114
113
-
#### Message Arguments: `path` and `target`
115
+
#### Message Arguments: `path` and `interaction`
114
116
115
-
Some messages (such as `select-item` and `hover-item`) include the arguments `path` and `target`:
117
+
The menu-interaction message contains two important arguments:`path` and `interaction`.
116
118
117
119
**`path`** is an array of zero-based integers representing the position of the item in the menu tree. For example, `[2, 1]` means the third child of the root, then the second child of that submenu.
118
120
119
-
**`target`** indicates what kind of menu element was interacted with. Possible values are:
120
-
-`item`: A regular final menu item (button). Selection of this item usually triggers an action and closes the menu.
121
-
-`submenu`: A submenu which contains other items. Selection of this item opens the submenu and does not close the menu.
122
-
-`parent`: The parent menu of the currently opened submenu. If this is selected, the current submenu will be closed and the parent menu will be shown.
121
+
**`interaction`** indicates what the user did. It can be one of the following: `'openMenu'`, `'openSubmenu'`, `'closeMenu'`, `'closeSubmenu'`, `'hoverParent'`, `'hoverCenter'`, `'hoverButton'`, `'hoverSubmenu'`, `'selectButton'`, `'activateMenu'`.
123
122
124
123
**Example**
125
124
126
125
This means the user selected the third item in the first submenu.
127
126
128
127
```json
129
128
{
130
-
"type": "select-item",
131
-
"target": "item",
129
+
"type": "menu-interaction",
130
+
"interaction": "selectButton",
132
131
"path": [0, 2]
133
132
}
134
133
```
@@ -140,6 +139,10 @@ The code snippet below demonstrates how to open a custom menu in Kando using Pyt
140
139
It reads the connection info from `ipc-info.json`, connects to the WebSocket server, and sends a `show-menu` message with a simple menu structure.
141
140
It then listens for user interactions and prints the selected item or cancellation.
142
141
142
+
<Asidetype="note"title="Complete Code Examples">
143
+
At the bottom of the page, you can find [a complete code example](#complete-code-examples) that includes error handling and API version checking.
print(f"Interaction: {interaction} at path {path}")
177
186
178
187
if__name__=="__main__":
179
188
asyncio.run(main())
@@ -182,27 +191,32 @@ if __name__ == "__main__":
182
191
183
192
## Listening to Menu Interactions
184
193
185
-
To observe all menu interactions (open, hover, select, cancel), of any opened menu, connect to the WebSocket server and send a `start-observing` message.
194
+
To observe all menu interactions (open, hover, select, cancel), of any menu opened by Kando, connect to the WebSocket server and send a `start-observing` message.
186
195
Kando will then send you events as they happen.
187
196
If you want to stop receiving events, send a `stop-observing` message.
With Kando 3.0, the IPC API has been updated to version 2. Previously, there were `select-item`, `hover-item`, and `cancel-menu` messages. In version 2, these have been replaced by a single `menu-interaction` message that provides more detailed information about the user's actions.
|`start-observing`| Client | Send this to start receiving menu interactions. events. |
194
207
|`stop-observing`| Client | Send this to stop receiving menu interaction events. |
195
-
|`open-menu`| Server | This will be sent by Kando when a menu is opened. |
196
-
|`hover-item`| Server |_Same as above_|
197
-
|`select-item`| Server |_Same as above_|
198
-
|`cancel-menu`| Server |_Same as above_|
208
+
|`menu-interaction`| Server |_Same as above_|
199
209
|`error`| Server |_Same as above_|
200
210
201
211
### Example code to observe menu interactions
202
212
203
213
The code snippet below demonstrates how to observe menu interactions in Kando using Python.
204
214
It connects to the WebSocket server, sends a `start-observing` message, and prints events as they happen (menu opened, item hovered, item selected, menu canceled).
205
215
216
+
<Asidetype="note"title="Complete Code Examples">
217
+
At the bottom of the page, you can find [a complete code example](#complete-code-examples) that includes error handling and API version checking.
0 commit comments