Description
I want to delete an object when a hardware button is pressed. There is no touch, I use lv_group_add_obj to add a text area.
What MCU/Processor/Board and compiler are you using?
nRF52
What do you want to achieve?
So far I have a menu created with lv_list. I want to open text area from particular button in the list. What I cannot do is going back from the text area to the list by pressing the back button. How can I read in the notification_cb() function the pressed button? Looks like LV_EVENT_KEY is not enough. I tried debugging the code and it never reached the notification_cb(). Instead, the buttons control the list that is below the created text area. So it’s again a focus problem, wright?
What have you tried so far?
The code listed below.
Code to reproduce
Add the relevant code snippets here.
The code block(s) should be between ```c
and ```
tags:
void notification_cb(lv_obj_t * obj, lv_event_t event)
{
switch(event) {
case LV_EVENT_KEY:
lv_obj_del(ta1);
break;
case LV_EVENT_FOCUSED:
lv_obj_del(ta1);
break;
}
}
void show_notification(void)
{
ta1 = lv_textarea_create(lv_scr_act(), NULL);
lv_obj_set_size(ta1, LV_HOR_RES_MAX-10, 60);//LV_VER_RES_MAX);
lv_obj_align(ta1, NULL, LV_ALIGN_CENTER, -4, 0);
lv_textarea_set_text(ta1, "Notification text. This is a test notification text to check if the function is working good.");
lv_textarea_set_cursor_hidden(ta1, true);
lv_obj_set_event_cb(ta1, notification_cb);
lv_obj_set_state(ta1, LV_STATE_FOCUSED);
lv_group_add_obj(g, ta1);
}
void notification_event_handler(lv_obj_t * obj, lv_event_t event)
{
switch(event) {
case LV_EVENT_PRESSED:
show_notification();
break;
}
}
Screenshot and/or video
n/a