update asserts

This commit is contained in:
Gabor Kiss-Vamosi
2021-02-08 09:53:03 +01:00
parent 956a367dbc
commit 7bec13c2b9
173 changed files with 4906 additions and 696 deletions

View File

@@ -0,0 +1,37 @@
#include "../../../lvgl.h"
#if LV_USE_KEYBOARD
static void ta_event_cb(lv_obj_t * ta, lv_event_t e)
{
lv_obj_t * kb = lv_event_get_user_data();
if(e == LV_EVENT_FOCUSED) {
lv_keyboard_set_textarea(kb, ta);
lv_obj_clear_flag(kb, LV_OBJ_FLAG_HIDDEN);
}
if(e == LV_EVENT_DEFOCUSED) {
lv_keyboard_set_textarea(kb, NULL);
lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
}
}
void lv_keyboard_example_1(void)
{
/*Create a keyboard to use it with an of the text areas*/
lv_obj_t *kb = lv_keyboard_create(lv_scr_act());
/*Create a text area. The keyboard will write here*/
lv_obj_t * ta;
ta = lv_textarea_create(lv_scr_act(), NULL);
lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_LEFT, 10, 10);
lv_obj_add_event_cb(ta, ta_event_cb, kb);
lv_textarea_set_placeholder_text(ta, "Hello");
ta = lv_textarea_create(lv_scr_act(), NULL);
lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_RIGHT, -10, 10);
lv_obj_add_event_cb(ta, ta_event_cb, kb);
lv_keyboard_set_textarea(kb, ta);
}
#endif

View File

@@ -0,0 +1,26 @@
# Create styles for the keyboard
rel_style = lv.style_t()
pr_style = lv.style_t()
lv.style_copy(rel_style, lv.style_btn_rel)
rel_style.body.radius = 0
rel_style.body.border.width = 1
lv.style_copy(pr_style, lv.style_btn_pr)
pr_style.body.radius = 0
pr_style.body.border.width = 1
# Create a keyboard and apply the styles
kb = lv.kb(lv.scr_act())
kb.set_cursor_manage(True)
kb.set_style(lv.kb.STYLE.BG, lv.style_transp_tight)
kb.set_style(lv.kb.STYLE.BTN_REL, rel_style)
kb.set_style(lv.kb.STYLE.BTN_PR, pr_style)
# Create a text area. The keyboard will write here
ta = lv.ta(lv.scr_act())
ta.align(None, lv.ALIGN.IN_TOP_MID, 0, 10)
ta.set_text("")
# Assign the text area to the keyboard
kb.set_ta(ta)