mirror of
https://github.com/esphome/esphome-docs.git
synced 2024-12-25 17:17:54 +01:00
[lvgl] Document lvgl.widget.focus
(#4172)
Co-authored-by: H. Árkosi Róbert <robreg@zsurob.hu>
This commit is contained in:
parent
89efc916c9
commit
53e10fff42
@ -10,7 +10,7 @@ embedded graphics library to create beautiful UIs for any MCU, MPU and display t
|
||||
|
||||
.. figure:: /components/lvgl/images/lvgl_main_screenshot.png
|
||||
|
||||
To use LVGL with a :ref:`display <display-hw>` in ESPHome, you'll need an ESP32 or supported ESP32 variant. PSRAM is not a strict requirement but it is generally recommended, especially for color displays with resolutions larger than approximately 240x240 pixels.
|
||||
To use LVGL with a :ref:`display <display-hw>` in ESPHome, you'll need an ESP32 or RP2040. PSRAM is not a strict requirement but it is generally recommended, especially for large color displays.
|
||||
|
||||
The graphic display should be configured with ``auto_clear_enabled: false`` and ``update_interval: never``, and should not have any ``lambda`` set.
|
||||
|
||||
@ -635,6 +635,56 @@ This :ref:`action <actions-action>` shows a specific page (including pages with
|
||||
then:
|
||||
- lvgl.page.show: secret_page # shorthand version
|
||||
|
||||
.. _lvgl-widget-focus-action:
|
||||
|
||||
``lvgl.widget.focus``
|
||||
*********************
|
||||
|
||||
This :ref:`action <actions-action>` moves the input focus to the nominated widget. Used mainly with encoder inputs
|
||||
to select a specific widget to receive input events. It may also allow the focus to be frozen on that widget,
|
||||
or can be used to move the focus to the next or previous widget in the focus group.
|
||||
|
||||
The required config options take one of several forms:
|
||||
|
||||
- **id** (**Required**): The ID of the widget to be given focus.
|
||||
- **freeze** (*Optional*, boolean): If true will lock the focus to this widget.
|
||||
- **editing** (*Optional*, boolean): Sets the editing mode of the widget, i.e. encoder rotation will change the value
|
||||
of the widget, not move the focus. Defaults to false.
|
||||
|
||||
or
|
||||
|
||||
- **action** (**Required**): Should be one of ``next``, ``previous``, ``mark`` or ``restore``.
|
||||
- **group** (*Optional*): The ID of the group within which to move the focus. The default group will be used if not specified
|
||||
- **freeze** (*Optional*, boolean): If true will lock the focus to the now selected widget.
|
||||
|
||||
|
||||
The ``next`` and ``previous`` actions will move the focus to the next or previous widget within the group.
|
||||
The ``mark`` action will save the currently focused widget within the group, and restore it when the ``restore`` action is triggered.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
on_...:
|
||||
then:
|
||||
- lvgl.widget.focus:
|
||||
id: my_button
|
||||
freeze: true
|
||||
|
||||
on_...:
|
||||
then:
|
||||
- lvgl.widget.focus: my_button
|
||||
|
||||
on_...:
|
||||
then:
|
||||
- lvgl.widget.focus:
|
||||
group: encoder_group
|
||||
direction: next
|
||||
freeze: true
|
||||
|
||||
on_...:
|
||||
then:
|
||||
- lvgl.widget.focus: previous
|
||||
|
||||
|
||||
.. _lvgl-conditions:
|
||||
|
||||
Conditions
|
||||
|
@ -1807,9 +1807,15 @@ ESPHome implements as universal triggers the following interaction events genera
|
||||
- ``on_scroll``: The widget was scrolled.
|
||||
- ``on_focus``: The widget is focused.
|
||||
- ``on_defocus``: The widget is unfocused.
|
||||
- ``on_all_events``: Will be triggered on any event sent to the widget - this is useful for debugging.
|
||||
|
||||
These triggers can be applied directly to any widget in the LVGL configuration, *given that the widget itself supports generating such events*. For the widgets having a value, the triggers return the current value in variable ``x``; this variable may be used in lambdas defined within those triggers.
|
||||
|
||||
Each trigger also deliver an ``event`` parameter, which is a pointer to the LVGL C type ``lv_event_t``. This may be used in lambdas defined within those triggers. Refer to the `LVGL documentation <https://docs.lvgl.io/8.4/overview/event.html/>`_ for more information.
|
||||
|
||||
There are additional triggers for pages - each page may have an ``on_load`` and ``on_unload`` trigger. These will be called
|
||||
when the page becomes active or inactive respectively.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
# Example triggers:
|
||||
|
Loading…
Reference in New Issue
Block a user