Control of keyboard using lv_event_send

Description

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

PIC32MZ

What LVGL version are you using?

8.3

What do you want to achieve?

I want to control the lv_keyboard widget by sending it events. I am doing it like this:

KeyBoard = lv_keyboard_create(Screen);
int key = LV_KEY_RIGHT;
lv_event_send(KeyBoard, LV_EVENT_KEY, &key);

I expect to see the selected button move on the widget, but this does not happen.
How can I control the lv_keyboard widget using lv_event_send?
Thank you in advance for your help!

I have partially solved the problem. Before sending
lv_event_send(KeyBoard, LV_EVENT_KEY, &key);
I also need to send
lv_event_send(KeyBoard, LV_EVENT_FOCUSED, 0);
Now, by sending LV_KEY_RIGHT/LEFT/UP/DOWN, I can navigate between the buttons.
However, when I send LV_KEY_ENTER, the input is not added to the textarea, even though I have already linked it using
lv_keyboard_set_textarea(KeyBoard, TextArea);
Can someone help me with this?

1 Like

I found a complete solution. You need to instead of the correct code LV_KEY_ENTER send lv_event_send(KeyBoard, LV_EVENT_PRESSED, 0);

1 Like