1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

fix(indev): always save the last key (#5795)

This commit is contained in:
Gabor Kiss-Vamosi 2024-03-12 08:50:01 +01:00 committed by GitHub
parent 803ca4aa63
commit d7704b6ed8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -688,6 +688,10 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
i->keypad.last_state = LV_INDEV_STATE_RELEASED; /*To skip the processing of release*/
}
/*Save the last key. *It must be done here else `lv_indev_get_key` will return the last key in events*/
uint32_t prev_key = i->keypad.last_key;
i->keypad.last_key = data->key;
lv_group_t * g = i->group;
if(g == NULL) return;
@ -696,13 +700,6 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
const bool is_enabled = !lv_obj_has_state(indev_obj_act, LV_STATE_DISABLED);
/*Save the last key to compare it with the current latter on RELEASE*/
uint32_t prev_key = i->keypad.last_key;
/*Save the last key.
*It must be done here else `lv_indev_get_key` will return the last key in events*/
i->keypad.last_key = data->key;
/*Save the previous state so we can detect state changes below and also set the last state now
*so if any event handler on the way returns `LV_RESULT_INVALID` the last state is remembered
*for the next time*/