Lv_textarea_get_text(lv_obj_t * ta)

Description

I’m having a newbee problem with lv_textarea_get_text(lv_obj_t * xyz)

What MCU/Processor/Board and compiler are you using?

Arduino Giga R1 WiFi

What do you want to achieve?

simply get the text from a text area in connection with a keyboard.

What have you tried so far?

screen with text area and a keyboard associated with it. Event handler for Keyboard defined as below.
LV_EVENT_READY works as expected but I cannot get the entered text. When printing to the serial Monitor I receive a single random char.

Code to reproduce

Add the relevant code snippets here.
String my_PSWD = String(lv_textarea_get_text(ta));
Serial.println(my_PSWD);
The code block(s) should be between ```c and ``` tags:

static void kb_event_handler(lv_event_t *e) {
  lv_event_code_t code = lv_event_get_code(e);
  lv_obj_t *ta = (lv_obj_t *)lv_event_get_target(e);
  lv_obj_t *kb = (lv_obj_t *)lv_event_get_user_data(e);

  if (code == LV_EVENT_FOCUSED) {
    lv_keyboard_set_textarea(kb, ta);
    lv_obj_remove_flag(kb, LV_OBJ_FLAG_HIDDEN);
  }
  if (code == LV_EVENT_DEFOCUSED) {
    lv_keyboard_set_textarea(kb, NULL);
    lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
  }
  if (code == LV_EVENT_READY) {
    String my_PSWD = String(lv_textarea_get_text(ta));
    Serial.println(my_PSWD);
    // lv_keyboard_set_textarea(kb, NULL);
  }
}

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

Problem solved - after using the globally defined object for the TextArea (instead of the local *ta object).
I really thought ‘lv_event_get_target()’ is a pointer to the area, but obviously isn’t :slight_smile: