#pragma once #include "esp_err.h" #include "lvgl.h" #include "ui/events.h" /** * @brief Interaction Handler - manages user interactions * * This class is responsible for handling user inputs * such as touch events, button presses, and gestures. * It routes these interactions to the appropriate UI components * or apps based on the current context. And it also handles the respective UI widgets. * * For example, it manages: * Textarea focus and display of the on-screen keyboard */ class InteractionHandler { public: InteractionHandler() = default; ~InteractionHandler(); /** * @brief Initialize the Interaction Handler * * Sets up necessary event listeners and state. * * @return ESP_OK on success, error code otherwise */ esp_err_t init(lv_obj_t* app_container); /** * @brief Deinitialize the Interaction Handler * * Cleans up resources and event listeners. * * @return ESP_OK on success, error code otherwise */ esp_err_t deinit(void); /** * @brief Add keyboard support to a textarea widget * * @param text_area Pointer to the textarea lvgl object * @return esp_err_t ESP_OK on success, error code otherwise */ esp_err_t register_text_area_keyboard_support(lv_obj_t* text_area); private: // Event handler for keyboard show/hide events // It should be registered with event callbacks of the keyboard object void on_keyboard_event_(lv_event_t* e); esp_err_t show_keyboard_for_textarea_(lv_obj_t* textarea); esp_err_t hide_keyboard_(void); // Pointers to key UI objects, owned by UIHandler lv_obj_t* app_container_ = nullptr; // owned keyboard object lv_obj_t* keyboard_ = nullptr; // Currently focused textarea, reference only lv_obj_t* focused_textarea_ = nullptr; InteractionHandler(const InteractionHandler&) = delete; InteractionHandler& operator=(const InteractionHandler&) = delete; };