mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-25 14:22:27 +03:00
9a02e23dc7
* New js modules documentation added * Documentation: Spelling and formatting Co-authored-by: ElectronicsInFocus <rnadyrshin@gmail.com> Co-authored-by: あく <alleteam@gmail.com>
49 lines
934 B
Markdown
49 lines
934 B
Markdown
# js_submenu {#js_submenu}
|
|
|
|
# Submenu module
|
|
```js
|
|
let submenu = require("submenu");
|
|
```
|
|
# Methods
|
|
|
|
## setHeader
|
|
Set the submenu header text.
|
|
|
|
### Parameters
|
|
- header (string): The submenu header text
|
|
|
|
### Example
|
|
```js
|
|
submenu.setHeader("Select an option:");
|
|
```
|
|
|
|
## addItem
|
|
Add a new submenu item.
|
|
|
|
### Parameters
|
|
- label (string): The submenu item label text
|
|
- id (number): The submenu item ID, must be a Uint32 number
|
|
|
|
### Example
|
|
```js
|
|
submenu.addItem("Option 1", 1);
|
|
submenu.addItem("Option 2", 2);
|
|
submenu.addItem("Option 3", 3);
|
|
```
|
|
|
|
## show
|
|
Show a submenu that was previously configured using `setHeader()` and `addItem()` methods.
|
|
|
|
### Returns
|
|
The ID of the submenu item that was selected, or `undefined` if the BACK button was pressed.
|
|
|
|
### Example
|
|
```js
|
|
let selected = submenu.show();
|
|
if (selected === undefined) {
|
|
// if BACK button was pressed
|
|
} else if (selected === 1) {
|
|
// if item with ID 1 was selected
|
|
}
|
|
```
|