Add docs for select has_option(...) and has_index(...) (#2065)

Co-authored-by: Maurice Makaay <mmakaay1@xs4all.net>
This commit is contained in:
Maurice Makaay 2022-05-11 00:58:32 +02:00 committed by GitHub
parent 528f0bfba9
commit c51c935bf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 1 deletions

View File

@ -282,7 +282,7 @@ advanced stuff (see the full API Reference for more info).
auto size = id(my_select).size();
ESP_LOGI("main", "Select has %d options", size);
- ``.index_of(<option name>)``: Retrieve the index offset for an option value.
- ``.index_of(<option value>)``: Retrieve the index offset for an option value.
.. code-block:: cpp
@ -317,6 +317,24 @@ advanced stuff (see the full API Reference for more info).
ESP_LOGE("main", "Index %d does not exist", index);
}
- ``.has_option(<option value>)``: Check if the select contains the given option value.
.. code-block:: cpp
auto option = "Happy";
if (id(my_select).has_option(option)) {
ESP_LOGI("main", "Select has option '%s'", option);
}
- ``.has_index(<index offset>)``: Check if the select contains an option value for the given index offset.
.. code-block:: cpp
auto index = 3;
if (id(my_select).has_index(index)) {
ESP_LOGI("main", "Select has index offset %d", index);
}
See Also
--------