Keyboard between textareas

Hello guys, I have been playing with the textarea, and noticed that once I closed the keyboard, it gets removed from the screen, however the variable that used to contain it is not null and gets difficult to know if it was closed or is still opened, I added another var to control its state but I feel it is not very user friendly, additionally, if I set my own callback looks like the previous one doesnt get called, this is my code if someone has a better approach:

static void ta_event_cb(lv_obj_t * ta, lv_event_t event)
{
    if(event == LV_EVENT_CLICKED) {
        /* Focus on the clicked text area */
        if(kbOpened == false) {
            kb = lv_keyboard_create(lv_scr_act(), NULL);
            lv_obj_set_event_cb(kb, mykb_event_cb);
            kbOpened = true;
        }
        
        lv_keyboard_set_textarea(kb, ta);
        lv_obj_set_size(kb,  LV_HOR_RES, LV_VER_RES / 2);
        lv_keyboard_set_cursor_manage(kb, true); 
    }

    else if(event == LV_EVENT_INSERT) {

        const char * str = lv_textarea_get_text(ta);
        if(str[0] == '\n') {
            printf("Ready\n");
        }
    }
}

and my custom callback

void mykb_event_cb(lv_obj_t * kb, lv_event_t event){
    lv_keyboard_def_event_cb(kb, event);
    if(event == LV_EVENT_CANCEL) {
        lv_keyboard_set_textarea(kb, NULL); /*De-assign the text area  to hide it cursor if needed*/
        lv_obj_del(kb);
        kbOpened = false;
    }
}

Hi,

It’s really not that intuitive but I can imagine a better approach now.

We could indicate in the text area that it is de-assigned from the keyboard but it does not necessarily mean that the keyboard is deleted. Maybe you are just clicked to another text area. So it should be processed by the keyboard.

If we called the

  lv_keyboard_set_textarea(kb, NULL); /*De-assign the text area  to hide it cursor if needed*/
  lv_obj_del(kb);

automatically even if you set a custom even handler there would be no way to overwrite this behavior.