i try to send a LV_KEY_RIGHT/DOWN LV_KEY_LEFT/UP LY_KEY_ENTER to a dropdown list,but it has no effect.
May I ask how to achieve this?
i try to do this again
it still has not effect.
I tried again for half a day。
group = lv_group_create();
lv_group_set_editing(group, false);
lv_group_add_obj(group, ddlist);
lv_group_send_data(group, LV_KEY_DOWN);
lv_group_send_data(group, LV_KEY_UP);
lv_group_send_data(group, LV_KEY_ENTER);
This way it can move the selection of ddList , but it can not apply the selected option for
LV_KEY_ENTER。
I tried something else in order to apply the selected option, but still no effect。
id = lv_dropdown_get_selected(ddlist);
printf("selected id = %d", id);
lv_dropdown_set_selected(ddlist, id); //unavailable id's value changed by move list,but invalid
//lv_dropdown_set_selected(ddlist, 0); //avaliable Direct assignment is valid.
lv_dropdown_close(ddlist);
i can already move dropdown list, so i want to apply the selected option。Through the above method,it still no effect。
LV_KEY_ENTER
wasn’t processed by the dropdown. If you hit the enter key LV_EVENT_CLICK
is also sent and only it was handled. I’ve pushed a fix for it.
With the latest v8 it worked for me:
lv_dropdown_open(dd);
uint32_t t = LV_KEY_DOWN;
lv_event_send(dd, LV_EVENT_KEY, &t);
lv_event_send(dd, LV_EVENT_KEY, &t);
lv_event_send(dd, LV_EVENT_KEY, &t);
t = LV_KEY_ENTER;
lv_event_send(dd, LV_EVENT_KEY, &t);
i try to use the four ways. it is failing.
I doesn’t work because you send the keys from an event.
I’ve fine tuned my earlier fix. Now it should work from events too.
I’m sorry that I still don’t understand what you mean. Could you please tell me some examples
I’ve also modified the spinbox example like this:
static lv_obj_t * dd;
static void lv_spinbox_increment_event_cb(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);
if(code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LONG_PRESSED_REPEAT) {
uint32_t k = LV_KEY_UP;
lv_event_send(dd, LV_EVENT_KEY, &k);
}
}
static void lv_spinbox_decrement_event_cb(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);
if(code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LONG_PRESSED_REPEAT) {
uint32_t k = LV_KEY_DOWN;
lv_event_send(dd, LV_EVENT_KEY, &k);
}
}
static void lv_spinbox_enter_event_cb(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);
if(code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LONG_PRESSED_REPEAT) {
uint32_t k = LV_KEY_ENTER;
lv_event_send(dd, LV_EVENT_KEY, &k);
}
}
void dropdpwn_key_send(void)
{
dd = lv_dropdown_create(lv_scr_act());
lv_obj_set_width(dd, 150);
lv_obj_center(dd);
lv_obj_update_layout(dd);
lv_coord_t h = lv_obj_get_height(dd);
lv_obj_t * btn = lv_btn_create(lv_scr_act());
lv_obj_set_size(btn, h, h);
lv_obj_align_to(btn, dd, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
lv_obj_set_style_bg_img_src(btn, LV_SYMBOL_PLUS, 0);
lv_obj_add_event_cb(btn, lv_spinbox_increment_event_cb, LV_EVENT_ALL, NULL);
btn = lv_btn_create(lv_scr_act());
lv_obj_set_size(btn, h, h);
lv_obj_align_to(btn, dd, LV_ALIGN_OUT_LEFT_MID, -5, 0);
lv_obj_set_style_bg_img_src(btn, LV_SYMBOL_MINUS, 0);
lv_obj_add_event_cb(btn, lv_spinbox_decrement_event_cb, LV_EVENT_ALL, NULL);
btn = lv_btn_create(lv_scr_act());
lv_obj_align_to(btn, dd, LV_ALIGN_OUT_TOP_MID, 0, -10);
lv_obj_add_event_cb(btn, lv_spinbox_enter_event_cb, LV_EVENT_ALL, NULL);
}
kisvegabor:
static lv_obj_t * dd;
static void lv_spinbox_increment_event_cb(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);
if(code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LONG_PRESSED_REPEAT) {
uint32_t k = LV_KEY_UP;
lv_event_send(dd, LV_EVENT_KEY, &k);
}
}
static void lv_spinbox_decrement_event_cb(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);
if(code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LONG_PRESSED_REPEAT) {
uint32_t k = LV_KEY_DOWN;
lv_event_send(dd, LV_EVENT_KEY, &k);
}
}
static void lv_spinbox_enter_event_cb(lv_event_t * e)
{
lv_event_code_t code = lv_event_get_code(e);
if(code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LONG_PRESSED_REPEAT) {
uint32_t k = LV_KEY_ENTER;
lv_event_send(dd, LV_EVENT_KEY, &k);
}
}
void dropdpwn_key_send(void)
{
dd = lv_dropdown_create(lv_scr_act());
lv_obj_set_width(dd, 150);
lv_obj_center(dd);
lv_obj_update_layout(dd);
lv_coord_t h = lv_obj_get_height(dd);
lv_obj_t * btn = lv_btn_create(lv_scr_act());
lv_obj_set_size(btn, h, h);
lv_obj_align_to(btn, dd, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
lv_obj_set_style_bg_img_src(btn, LV_SYMBOL_PLUS, 0);
lv_obj_add_event_cb(btn, lv_spinbox_increment_event_cb, LV_EVENT_ALL, NULL);
btn = lv_btn_create(lv_scr_act());
lv_obj_set_size(btn, h, h);
lv_obj_align_to(btn, dd, LV_ALIGN_OUT_LEFT_MID, -5, 0);
lv_obj_set_style_bg_img_src(btn, LV_SYMBOL_MINUS, 0);
lv_obj_add_event_cb(btn, lv_spinbox_decrement_event_cb, LV_EVENT_ALL, NULL);
btn = lv_btn_create(lv_scr_act());
lv_obj_align_to(btn, dd, LV_ALIGN_OUT_TOP_MID, 0, -10);
lv_obj_add_event_cb(btn, lv_spinbox_enter_event_cb, LV_EVENT_ALL, NULL);
}
This code should be v8. I am currently using V7.11.0. Could you please provide an example of V7.11.0? because I have everything else now, except this dropdown list “confirm” implementation.
kisvegabor:
LV_EVENT_CLICK
I tried running this code in a v8 simulator.
It can move up and down, but it still doesn’t confirm.
Please share to whole example to reproduce the issue.
Thank you very much. I tried it in the company some time ago, but it didn’t work. I think I didn’t get it right.