How to read an added text in a text area

Description

I get a numeric text in a text area through a button matrix pad using the lv_ta_add_text(btnm1_textarea, txt);
I have been trying to convert a text in a text area to a numeric value.
But I don’t know how to read the text in the btnm1_textarea.

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

STM32F7 series

What do you want to achieve?

How can I read the added text in a text area.

What have you tried so far?

Code to reproduce

static lv_obj_t * btnm1_textarea;

static void btnm_event_cb(lv_obj_t * obj, lv_event_t event)
{
  if(event == LV_EVENT_CLICKED) {
    const char* txt = lv_btnm_get_active_btn_text(obj);
    if(txt != NULL)
    {
      if(strcmp(txt, "OK") == 0)
      {
         // convert a text in the text area to a numeric value
         // save a numeric value to a variable
      }
      else
      {
        lv_ta_add_text(btnm1_textarea, txt);
      }
...
}

This is a C question, not a LittlevGL question :slightly_smiling_face:. But I think you are looking for strtol or strtoul.

Thanks, but my question is how to get the text from the textarea object.
Dose the textarea object have the member containing the text?

Have a look at the documentation.

Why didn’t I find it? :pensive:
Thanks a lot.

1 Like