Important: unclear posts may not receive useful answers.
Before posting
- Get familiar with Markdown to format and structure your post
- Be sure to update lvgl from the latest version from the
master
branch.- Be sure you have checked the relevant part of the documentation.
- If applicable use the Simulator to eliminate hardware related issues.
Delete this section if you read and applied the mentioned points.
Description
I want to do some cooperation between textarea and keyboard, such as when click textarea, it shows keyboard, then when I clicked the LV_SYMBOL_KEYBOARD hide the keyboard and the textarea cursor. I found some problems in my code.
1、how to hide textarea cursor? It’s not so convenient compare with V6.0.2
2、If I simply create a keyboard, then I clicked the LV_SYMBOL_KEYBOARD, it can’t hide the keyboard.
3、In my code, ta_event_cb
. When I try to debug my code, once I clicked the textarea, It seems to run it in ta_event_cb
again and again, but the lv_event_code_t
code is different everytime.
4、If I add textarea through LV_EVENT_CLOSE
not through LV_EVENT_ALL
,then I found if I click one textarea, the keyboard will close, then I clicked this textarea again, it will not run into ta_event_cb
again, when I click another textaren it run it in ta_event_cb
again.
What MCU/Processor/Board and compiler are you using?
ARM335X
What LVGL version are you using?
V8.0.2
What do you want to achieve?
What have you tried so far?
Code to reproduce
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.
The code block(s) should be formatted like:
static void ta_event_cb(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t * ta = lv_event_get_target(e);
if(code == LV_EVENT_CLICKED || code == LV_EVENT_FOCUSED) {
/*Focus on the clicked text area*/
if(g_keyboard != NULL)
{
lv_obj_clear_flag(g_keyboard, LV_OBJ_FLAG_HIDDEN);
lv_keyboard_set_textarea(g_keyboard, ta);
}
}
else if(code == LV_EVENT_READY) {
LV_LOG_USER("Ready, current text: %s", lv_textarea_get_text(ta));
}
}
static void KeyboardEventCB(lv_event_t* event)
{
// lv_keyboard_def_event_cb(event);
//
lv_event_code_t code = lv_event_get_code(event);
//
// lv_obj_t* ta_of_kb = lv_keyboard_get_textarea(g_keyboard);
//
if(code == LV_EVENT_CANCEL)
{
// lv_textarea_t * ta = (lv_textarea_t *)ta_of_kb;
// ta->cursor.show = 0;
lv_obj_add_flag(g_keyboard, LV_OBJ_FLAG_HIDDEN);
}
}
void CreateKeyboard(lv_obj_t* parent, lv_coord_t w, lv_coord_t h)
{
g_keyboard = lv_keyboard_create(parent);
lv_obj_set_size(g_keyboard, w, h);
lv_obj_align_to(g_keyboard, parent, LV_ALIGN_BOTTOM_RIGHT, 0, 0);
// lv_obj_add_event_cb(g_keyboard, KeyboardEventCB, LV_EVENT_CANCEL, NULL);
// lv_obj_add_flag(g_keyboard, LV_OBJ_FLAG_HIDDEN);
}
int main()
{
CreateKeyboard(lv_scr_act(), 940, 150);
lv_obj_clear_flag(g_keyboard, LV_OBJ_FLAG_HIDDEN);
lv_obj_t * text_ta = lv_textarea_create(lv_scr_act());
lv_textarea_set_one_line(text_ta, true);
lv_textarea_set_password_mode(text_ta, false);
lv_obj_set_width(text_ta, lv_pct(40));
lv_obj_add_event_cb(text_ta, ta_event_cb, LV_EVENT_ALL, NULL);
lv_obj_align_to(text_ta, NULL, LV_ALIGN_TOP_LEFT, 0, 60);
lv_obj_t * text_ta1 = lv_textarea_create(lv_scr_act());
lv_textarea_set_one_line(text_ta1, true);
lv_textarea_set_password_mode(text_ta1, false);
lv_obj_set_width(text_ta1, lv_pct(40));
lv_obj_add_event_cb(text_ta1, ta_event_cb, LV_EVENT_ALL, NULL);
lv_obj_align_to(text_ta1, NULL, LV_ALIGN_TOP_RIGHT, 0, 60);
}
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.