Skip to content

Commit

Permalink
fix(obj, switch) do not send LV_EVENT_VALUE_CHANGED twice
Browse files Browse the repository at this point in the history
fixes #2330
  • Loading branch information
kisvegabor committed Jun 22, 2021
1 parent 52d1c2e commit 713b39e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/core/lv_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,12 @@ static void lv_obj_event(const lv_obj_class_t * class_p, lv_event_t * e)
else if(c == LV_KEY_LEFT || c == LV_KEY_DOWN) {
lv_obj_clear_state(obj, LV_STATE_CHECKED);
}
lv_res_t res = lv_event_send(obj, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return;

/*With Enter LV_EVENT_RELEASED will send VALUE_CHANGE event*/
if(c != LV_KEY_ENTER) {
lv_res_t res = lv_event_send(obj, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return;
}
}
}
else if(code == LV_EVENT_FOCUSED) {
Expand Down
4 changes: 0 additions & 4 deletions src/widgets/lv_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ static void lv_switch_event(const lv_obj_class_t * class_p, lv_event_t * e)
*s = LV_MAX(*s, lv_obj_calculate_ext_draw_size(obj, LV_PART_INDICATOR));
}
else if(code == LV_EVENT_CLICKED) {
uint32_t v = lv_obj_get_state(obj) & LV_STATE_CHECKED ? 1 : 0;
res = lv_event_send(obj, LV_EVENT_VALUE_CHANGED, &v);
if(res != LV_RES_OK) return;

lv_obj_invalidate(obj);
}
else if(code == LV_EVENT_DRAW_MAIN) {
Expand Down

0 comments on commit 713b39e

Please sign in to comment.