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

btn: fix lv_btn_set_state to remove DIABLED state if other state is set

This commit is contained in:
Gabor Kiss-Vamosi 2020-03-04 11:09:10 +01:00
parent cec2660724
commit 5c6a7fa6d3

View File

@ -134,20 +134,21 @@ void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state)
switch(state) { switch(state) {
case LV_BTN_STATE_RELEASED: case LV_BTN_STATE_RELEASED:
lv_obj_clear_state(btn, LV_STATE_PRESSED | LV_STATE_CHECKED); lv_obj_clear_state(btn, LV_STATE_PRESSED | LV_STATE_CHECKED | LV_STATE_DISABLED);
break; break;
case LV_BTN_STATE_PRESSED: case LV_BTN_STATE_PRESSED:
lv_obj_clear_state(btn, LV_STATE_CHECKED); lv_obj_clear_state(btn, LV_STATE_CHECKED | LV_STATE_DISABLED);
lv_obj_add_state(btn, LV_STATE_PRESSED); lv_obj_add_state(btn, LV_STATE_PRESSED);
break; break;
case LV_BTN_STATE_CHECKED_RELEASED: case LV_BTN_STATE_CHECKED_RELEASED:
lv_obj_add_state(btn, LV_STATE_CHECKED); lv_obj_add_state(btn, LV_STATE_CHECKED);
lv_obj_clear_state(btn, LV_STATE_PRESSED); lv_obj_clear_state(btn, LV_STATE_PRESSED | LV_STATE_DISABLED);
break; break;
case LV_BTN_STATE_CHECKED_PRESSED: case LV_BTN_STATE_CHECKED_PRESSED:
lv_obj_add_state(btn, LV_STATE_PRESSED | LV_STATE_CHECKED); lv_obj_add_state(btn, LV_STATE_PRESSED | LV_STATE_CHECKED | LV_STATE_DISABLED);
break; break;
case LV_BTN_STATE_DISABLED: case LV_BTN_STATE_DISABLED:
lv_obj_clear_state(btn, LV_STATE_PRESSED | LV_STATE_CHECKED);
lv_obj_add_state(btn, LV_STATE_DISABLED); lv_obj_add_state(btn, LV_STATE_DISABLED);
break; break;
} }