mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
* Revert "Update ESP LCD Touch dependencies (#63)" This reverts commit cbd0355cec25e9d0f83f328ac2cae78e0e3b83e3. * Revert "Updated board configs for LVGL changes (#62)" This reverts commit 52d769854f6805407f7ee08adaa78b3a406fa13e. * Revert "Various updates (#60)" This reverts commit a8a664703b131963222d2035a3a85ecede29e633.
61 lines
1.5 KiB
C
61 lines
1.5 KiB
C
#include "gui_i.h"
|
|
|
|
#include "tactility_config.h"
|
|
#include "ui/lvgl_keypad.h"
|
|
#include "ui/lvgl_sync.h"
|
|
|
|
extern Gui* gui;
|
|
|
|
static void show_keyboard(lv_event_t* event) {
|
|
gui_keyboard_show(event->current_target);
|
|
lv_obj_scroll_to_view(event->current_target, LV_ANIM_ON);
|
|
}
|
|
|
|
static void hide_keyboard(TT_UNUSED lv_event_t* event) {
|
|
gui_keyboard_hide();
|
|
}
|
|
|
|
bool gui_keyboard_is_enabled() {
|
|
return !tt_lvgl_keypad_is_available() || TT_CONFIG_FORCE_ONSCREEN_KEYBOARD;
|
|
}
|
|
|
|
void gui_keyboard_show(lv_obj_t* textarea) {
|
|
gui_lock();
|
|
|
|
if (gui->keyboard) {
|
|
lv_obj_clear_flag(gui->keyboard, LV_OBJ_FLAG_HIDDEN);
|
|
lv_keyboard_set_textarea(gui->keyboard, textarea);
|
|
}
|
|
|
|
gui_unlock();
|
|
}
|
|
|
|
void gui_keyboard_hide() {
|
|
gui_lock();
|
|
|
|
if (gui->keyboard) {
|
|
lv_obj_add_flag(gui->keyboard, LV_OBJ_FLAG_HIDDEN);
|
|
}
|
|
|
|
gui_unlock();
|
|
}
|
|
|
|
void gui_keyboard_add_textarea(lv_obj_t* textarea) {
|
|
gui_lock();
|
|
tt_check(tt_lvgl_lock(0), "lvgl should already be locked before calling this method");
|
|
|
|
if (gui_keyboard_is_enabled()) {
|
|
lv_obj_add_event_cb(textarea, show_keyboard, LV_EVENT_FOCUSED, NULL);
|
|
lv_obj_add_event_cb(textarea, hide_keyboard, LV_EVENT_DEFOCUSED, NULL);
|
|
lv_obj_add_event_cb(textarea, hide_keyboard, LV_EVENT_READY, NULL);
|
|
}
|
|
|
|
// lv_obj_t auto-remove themselves from the group when they are destroyed (last checked in LVGL 8.3)
|
|
lv_group_add_obj(gui->keyboard_group, textarea);
|
|
|
|
tt_lvgl_keypad_activate(gui->keyboard_group);
|
|
|
|
tt_lvgl_unlock();
|
|
gui_unlock();
|
|
}
|