1
mirror of https://github.com/flipperdevices/flipperzero-firmware.git synced 2025-12-13 05:19:50 +04:00

New js modules documentation added (#3736)

* New js modules documentation added
* Documentation: Spelling and formatting

Co-authored-by: ElectronicsInFocus <rnadyrshin@gmail.com>
Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Ruslan Nadyrshin
2024-06-30 15:18:46 +04:00
committed by GitHub
parent 0b2827836d
commit 9a02e23dc7
7 changed files with 491 additions and 9 deletions

View File

@@ -0,0 +1,48 @@
# 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
}
```