KEYPAD, ENCODER: not send ENTER (process it in RELEASE signals)
This commit is contained in:
@@ -402,7 +402,6 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
if(i->proc.reset_query) return; /*The object might be deleted*/
|
||||
lv_obj_send_event(focused, LV_EVENT_PRESSED);
|
||||
if(i->proc.reset_query) return; /*The object might be deleted*/
|
||||
lv_group_send_data(g, LV_GROUP_KEY_ENTER);
|
||||
}
|
||||
/*Move the focus on NEXT*/
|
||||
else if(data->key == LV_GROUP_KEY_NEXT) {
|
||||
@@ -587,7 +586,6 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
|
||||
/*The button was released on a non-editable object. Just send enter*/
|
||||
if(editable == false) {
|
||||
lv_group_send_data(g, LV_GROUP_KEY_ENTER);
|
||||
focused->signal_cb(focused, LV_SIGNAL_RELEASED, NULL);
|
||||
if(i->proc.reset_query) return; /*The object might be deleted*/
|
||||
|
||||
|
||||
@@ -340,8 +340,7 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
char c = *((char *)param);
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN ||
|
||||
c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP ||
|
||||
c == LV_GROUP_KEY_ENTER) {
|
||||
c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_UP) {
|
||||
lv_btn_set_state(ext->bullet, lv_btn_get_state(cb));
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
|
||||
@@ -687,14 +687,6 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
||||
lv_ddlist_pos_current_option(ddlist);
|
||||
lv_obj_invalidate(ddlist);
|
||||
}
|
||||
} else if(c == LV_GROUP_KEY_ENTER) {
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
if(lv_indev_get_type(indev) == LV_INDEV_TYPE_ENCODER) {
|
||||
lv_group_t * g = lv_obj_get_group(ddlist);
|
||||
if(lv_group_get_editing(g)) {
|
||||
lv_group_set_editing(g, false);
|
||||
}
|
||||
}
|
||||
} else if(c == LV_GROUP_KEY_ESC) {
|
||||
if(ext->opened) {
|
||||
ext->opened = 0;
|
||||
@@ -767,8 +759,16 @@ static lv_res_t release_handler(lv_obj_t * ddlist)
|
||||
lv_ddlist_refr_size(ddlist, true);
|
||||
} else {
|
||||
|
||||
/*Search the clicked option (For KEYPAD and ENCODER the new value should be already set)*/
|
||||
/*Leave edit mode once a new item is selected*/
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
if(lv_indev_get_type(indev) == LV_INDEV_TYPE_ENCODER) {
|
||||
lv_group_t * g = lv_obj_get_group(ddlist);
|
||||
if(lv_group_get_editing(g)) {
|
||||
lv_group_set_editing(g, false);
|
||||
}
|
||||
}
|
||||
|
||||
/*Search the clicked option (For KEYPAD and ENCODER the new value should be already set)*/
|
||||
if(lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER || lv_indev_get_type(indev) == LV_INDEV_TYPE_BUTTON) {
|
||||
lv_point_t p;
|
||||
lv_indev_get_point(indev, &p);
|
||||
|
||||
@@ -92,7 +92,7 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
ext->anim_time = LV_LIST_FOCUS_TIME;
|
||||
ext->single_mode = false;
|
||||
ext->size = 0;
|
||||
|
||||
|
||||
#if LV_USE_GROUP
|
||||
ext->last_sel = NULL;
|
||||
ext->selected_btn = NULL;
|
||||
@@ -345,40 +345,40 @@ void lv_list_set_style(lv_obj_t * list, lv_list_style_t type, lv_style_t * style
|
||||
lv_obj_t * btn;
|
||||
|
||||
switch(type) {
|
||||
case LV_LIST_STYLE_BG:
|
||||
lv_page_set_style(list, LV_PAGE_STYLE_BG, style);
|
||||
/*style change signal will call 'refr_btn_width' */
|
||||
break;
|
||||
case LV_LIST_STYLE_SCRL:
|
||||
lv_page_set_style(list, LV_PAGE_STYLE_SCRL, style);
|
||||
refr_btn_width(list);
|
||||
break;
|
||||
case LV_LIST_STYLE_SB:
|
||||
lv_page_set_style(list, LV_PAGE_STYLE_SB, style);
|
||||
break;
|
||||
case LV_LIST_STYLE_EDGE_FLASH:
|
||||
lv_page_set_style(list, LV_PAGE_STYLE_EDGE_FLASH, style);
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_REL:
|
||||
ext->styles_btn[LV_BTN_STATE_REL] = style;
|
||||
btn_style_refr = LV_BTN_STYLE_REL;
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_PR:
|
||||
ext->styles_btn[LV_BTN_STATE_PR] = style;
|
||||
btn_style_refr = LV_BTN_STYLE_PR;
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_TGL_REL:
|
||||
ext->styles_btn[LV_BTN_STATE_TGL_REL] = style;
|
||||
btn_style_refr = LV_BTN_STYLE_TGL_REL;
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_TGL_PR:
|
||||
ext->styles_btn[LV_BTN_STATE_TGL_PR] = style;
|
||||
btn_style_refr = LV_BTN_STYLE_TGL_PR;
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_INA:
|
||||
ext->styles_btn[LV_BTN_STATE_INA] = style;
|
||||
btn_style_refr = LV_BTN_STYLE_INA;
|
||||
break;
|
||||
case LV_LIST_STYLE_BG:
|
||||
lv_page_set_style(list, LV_PAGE_STYLE_BG, style);
|
||||
/*style change signal will call 'refr_btn_width' */
|
||||
break;
|
||||
case LV_LIST_STYLE_SCRL:
|
||||
lv_page_set_style(list, LV_PAGE_STYLE_SCRL, style);
|
||||
refr_btn_width(list);
|
||||
break;
|
||||
case LV_LIST_STYLE_SB:
|
||||
lv_page_set_style(list, LV_PAGE_STYLE_SB, style);
|
||||
break;
|
||||
case LV_LIST_STYLE_EDGE_FLASH:
|
||||
lv_page_set_style(list, LV_PAGE_STYLE_EDGE_FLASH, style);
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_REL:
|
||||
ext->styles_btn[LV_BTN_STATE_REL] = style;
|
||||
btn_style_refr = LV_BTN_STYLE_REL;
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_PR:
|
||||
ext->styles_btn[LV_BTN_STATE_PR] = style;
|
||||
btn_style_refr = LV_BTN_STYLE_PR;
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_TGL_REL:
|
||||
ext->styles_btn[LV_BTN_STATE_TGL_REL] = style;
|
||||
btn_style_refr = LV_BTN_STYLE_TGL_REL;
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_TGL_PR:
|
||||
ext->styles_btn[LV_BTN_STATE_TGL_PR] = style;
|
||||
btn_style_refr = LV_BTN_STYLE_TGL_PR;
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_INA:
|
||||
ext->styles_btn[LV_BTN_STATE_INA] = style;
|
||||
btn_style_refr = LV_BTN_STYLE_INA;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -488,7 +488,7 @@ lv_obj_t * lv_list_get_prev_btn(const lv_obj_t * list, lv_obj_t * prev_btn)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the next button from list. (Starts from the bottom button)
|
||||
* @param list pointer to a list object
|
||||
* @param prev_btn pointer to button. Search the next after it.
|
||||
@@ -585,36 +585,36 @@ lv_style_t * lv_list_get_style(const lv_obj_t * list, lv_list_style_t type)
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
|
||||
switch(type) {
|
||||
case LV_LIST_STYLE_BG:
|
||||
style = lv_page_get_style(list, LV_PAGE_STYLE_BG);
|
||||
break;
|
||||
case LV_LIST_STYLE_SCRL:
|
||||
style = lv_page_get_style(list, LV_PAGE_STYLE_SB);
|
||||
break;
|
||||
case LV_LIST_STYLE_SB:
|
||||
style = lv_page_get_style(list, LV_PAGE_STYLE_SCRL);
|
||||
break;
|
||||
case LV_LIST_STYLE_EDGE_FLASH:
|
||||
style = lv_page_get_style(list, LV_PAGE_STYLE_EDGE_FLASH);
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_REL:
|
||||
style = ext->styles_btn[LV_BTN_STATE_REL];
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_PR:
|
||||
style = ext->styles_btn[LV_BTN_STATE_PR];
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_TGL_REL:
|
||||
style = ext->styles_btn[LV_BTN_STATE_TGL_REL];
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_TGL_PR:
|
||||
style = ext->styles_btn[LV_BTN_STATE_TGL_PR];
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_INA:
|
||||
style = ext->styles_btn[LV_BTN_STATE_INA];
|
||||
break;
|
||||
default:
|
||||
style = NULL;
|
||||
break;
|
||||
case LV_LIST_STYLE_BG:
|
||||
style = lv_page_get_style(list, LV_PAGE_STYLE_BG);
|
||||
break;
|
||||
case LV_LIST_STYLE_SCRL:
|
||||
style = lv_page_get_style(list, LV_PAGE_STYLE_SB);
|
||||
break;
|
||||
case LV_LIST_STYLE_SB:
|
||||
style = lv_page_get_style(list, LV_PAGE_STYLE_SCRL);
|
||||
break;
|
||||
case LV_LIST_STYLE_EDGE_FLASH:
|
||||
style = lv_page_get_style(list, LV_PAGE_STYLE_EDGE_FLASH);
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_REL:
|
||||
style = ext->styles_btn[LV_BTN_STATE_REL];
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_PR:
|
||||
style = ext->styles_btn[LV_BTN_STATE_PR];
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_TGL_REL:
|
||||
style = ext->styles_btn[LV_BTN_STATE_TGL_REL];
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_TGL_PR:
|
||||
style = ext->styles_btn[LV_BTN_STATE_TGL_PR];
|
||||
break;
|
||||
case LV_LIST_STYLE_BTN_INA:
|
||||
style = ext->styles_btn[LV_BTN_STATE_INA];
|
||||
break;
|
||||
default:
|
||||
style = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
return style;
|
||||
@@ -752,10 +752,55 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
if(w != lv_area_get_width(param)) { /*Width changed*/
|
||||
refr_btn_width(list);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED ||
|
||||
sign == LV_SIGNAL_PRESSED ||
|
||||
sign == LV_SIGNAL_PRESSING ||
|
||||
sign == LV_SIGNAL_LONG_PRESS ||
|
||||
sign == LV_SIGNAL_LONG_PRESS_REP)
|
||||
{
|
||||
/*If pressed/released etc by a KEYPAD or ENCODER delegate signal to the button*/
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
if(indev_type == LV_INDEV_TYPE_KEYPAD ||
|
||||
(indev_type == LV_INDEV_TYPE_ENCODER && lv_group_get_editing(lv_obj_get_group(list))))
|
||||
{
|
||||
/*Get the 'pressed' button*/
|
||||
lv_obj_t * btn = NULL;
|
||||
btn = lv_list_get_prev_btn(list, btn);
|
||||
while(btn != NULL) {
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
|
||||
btn = lv_list_get_prev_btn(list, btn);
|
||||
}
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
|
||||
if(btn) {
|
||||
if(sign == LV_SIGNAL_PRESSED) {
|
||||
lv_obj_send_event(btn, LV_EVENT_PRESSED);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSING) {
|
||||
lv_obj_send_event(btn, LV_EVENT_PRESSING);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_LONG_PRESS) {
|
||||
lv_obj_send_event(btn, LV_EVENT_LONG_PRESSED);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
|
||||
lv_obj_send_event(btn, LV_EVENT_LONG_PRESSED_REPEAT);
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
ext->last_sel = btn;
|
||||
if(indev->proc.long_pr_sent == 0) lv_obj_send_event(btn, LV_EVENT_SHORT_CLICKED);
|
||||
lv_obj_send_event(btn, LV_EVENT_CLICKED);
|
||||
lv_obj_send_event(btn, LV_EVENT_RELEASED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_STYLE_CHG) {
|
||||
/*Because of the possible change of horizontal and vertical padding refresh buttons width */
|
||||
refr_btn_width(list);
|
||||
} else if(sign == LV_SIGNAL_FOCUS) {
|
||||
}
|
||||
else if(sign == LV_SIGNAL_FOCUS) {
|
||||
|
||||
#if LV_USE_GROUP
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
@@ -834,21 +879,6 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param)
|
||||
lv_obj_t * btn = lv_list_get_next_btn(list, NULL);
|
||||
if(btn) lv_list_set_btn_selected(list, btn);
|
||||
}
|
||||
} else if(c == LV_GROUP_KEY_ENTER) {
|
||||
/*Get the 'pressed' button*/
|
||||
lv_obj_t * btn = NULL;
|
||||
btn = lv_list_get_prev_btn(list, btn);
|
||||
while(btn != NULL) {
|
||||
if(lv_btn_get_state(btn) == LV_BTN_STATE_PR) break;
|
||||
btn = lv_list_get_prev_btn(list, btn);
|
||||
}
|
||||
|
||||
if(btn != NULL) {
|
||||
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
|
||||
ext->last_sel = btn;
|
||||
res = lv_obj_send_event(btn, LV_EVENT_CLICKED);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
|
||||
@@ -402,16 +402,6 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
||||
if(ext->ddlist.sel_opt_id > 0) {
|
||||
lv_roller_set_selected(roller, ext->ddlist.sel_opt_id - 1, true);
|
||||
}
|
||||
} else if(c == LV_GROUP_KEY_ENTER) {
|
||||
ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Set the entered value as default*/
|
||||
res = lv_obj_send_event(roller, LV_EVENT_VALUE_CHANGED);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
#if LV_USE_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(roller);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/
|
||||
#endif
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
@@ -472,6 +462,12 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign,
|
||||
if(id < 0) id = 0;
|
||||
if(id >= ext->ddlist.option_cnt) id = ext->ddlist.option_cnt - 1;
|
||||
ext->ddlist.sel_opt_id = id;
|
||||
ext->ddlist.sel_opt_id_ori = id;
|
||||
#if LV_USE_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(roller);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/
|
||||
#endif
|
||||
res = lv_obj_send_event(roller, LV_EVENT_VALUE_CHANGED);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
|
||||
@@ -477,6 +477,17 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
|
||||
} else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) {
|
||||
if(ext->drag_value != LV_SLIDER_NOT_PRESSED) lv_slider_set_value(slider, ext->drag_value, false);
|
||||
ext->drag_value = LV_SLIDER_NOT_PRESSED;
|
||||
|
||||
#if LV_USE_GROUP
|
||||
/*Leave edit mode if released. (No need to wait for LONG_PRESS) */
|
||||
lv_group_t * g = lv_obj_get_group(slider);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
if(editing) lv_group_set_editing(g, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
} else if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
/* The knob size depends on slider size.
|
||||
* During the drawing method the ext. size is used by the knob so refresh the ext. size.*/
|
||||
@@ -504,15 +515,6 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
|
||||
|
||||
ext->drag_value = LV_SLIDER_NOT_PRESSED;
|
||||
|
||||
#if LV_USE_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(slider);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
/*Encoders need special handling*/
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER && c == LV_GROUP_KEY_ENTER) {
|
||||
if(editing) lv_group_set_editing(g, false);
|
||||
}
|
||||
#endif
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
|
||||
lv_slider_set_value(slider, lv_slider_get_value(slider) + 1, true);
|
||||
res = lv_obj_send_event(slider, LV_EVENT_VALUE_CHANGED);
|
||||
|
||||
@@ -335,6 +335,27 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
|
||||
}
|
||||
buf->type[i] = "lv_spinbox";
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
/*If released with an ENCODER then move to the nexxt digit*/
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
if(lv_indev_get_type(indev) == LV_INDEV_TYPE_ENCODER) {
|
||||
if(lv_group_get_editing(lv_obj_get_group(spinbox))) {
|
||||
if(ext->step > 1) {
|
||||
lv_spinbox_step_next(spinbox);
|
||||
} else {
|
||||
/*Restart from the MSB*/
|
||||
ext->step = 1;
|
||||
uint32_t i;
|
||||
for(i = 0; i < ext->digit_count; i++) {
|
||||
int32_t new_step = ext->step * 10;
|
||||
if(new_step >= ext->range_max) break;
|
||||
ext->step = new_step;
|
||||
}
|
||||
lv_spinbox_step_previous(spinbox);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
|
||||
@@ -353,22 +374,6 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
|
||||
else if(c == LV_GROUP_KEY_DOWN) {
|
||||
lv_spinbox_decrement(spinbox);
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_ENTER) {
|
||||
|
||||
if(ext->step > 1) {
|
||||
lv_spinbox_step_next(spinbox);
|
||||
} else {
|
||||
/*Restart from the MSB*/
|
||||
ext->step = 1;
|
||||
uint32_t i;
|
||||
for(i = 0; i < ext->digit_count; i++) {
|
||||
int32_t new_step = ext->step * 10;
|
||||
if(new_step >= ext->range_max) break;
|
||||
ext->step = new_step;
|
||||
}
|
||||
lv_spinbox_step_previous(spinbox);
|
||||
}
|
||||
}
|
||||
else {
|
||||
lv_ta_add_char(spinbox, c);
|
||||
}
|
||||
|
||||
@@ -344,6 +344,8 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
|
||||
if(lv_sw_get_state(sw)) lv_sw_off(sw, true);
|
||||
else lv_sw_on(sw, true);
|
||||
|
||||
res = lv_obj_send_event(sw, LV_EVENT_VALUE_CHANGED);
|
||||
if(res != LV_RES_OK) return res;
|
||||
}
|
||||
/*If the switch was dragged then calculate the new state based on the current position*/
|
||||
else {
|
||||
@@ -356,11 +358,7 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
char c = *((char *)param);
|
||||
if(c == LV_GROUP_KEY_ENTER) {
|
||||
lv_sw_toggle(sw, true);
|
||||
res = lv_obj_send_event(sw, LV_EVENT_VALUE_CHANGED);
|
||||
if(res != LV_RES_OK) return res;
|
||||
} else if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
|
||||
lv_slider_set_value(sw, LV_SW_MAX_VALUE, true);
|
||||
res = lv_obj_send_event(sw, LV_EVENT_VALUE_CHANGED);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
@@ -574,27 +574,33 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
|
||||
ext->tab_name_ptr = NULL;
|
||||
ext->btns = NULL; /*These objects were children so they are already invalid*/
|
||||
ext->content = NULL;
|
||||
} else if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CORD_CHG) {
|
||||
if(ext->content != NULL &&
|
||||
(lv_obj_get_width(tabview) != lv_area_get_width(param) ||
|
||||
lv_obj_get_height(tabview) != lv_area_get_height(param))) {
|
||||
tabview_realign(tabview);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROLL) {
|
||||
}
|
||||
else if(sign == LV_SIGNAL_RELEASED) {
|
||||
/*If released by a KEYPAD or ENCODER then really the tab buttons should be released.
|
||||
* So simulate a CLICK on the tab buttons*/
|
||||
lv_indev_t * indev = lv_indev_get_act();
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(indev);
|
||||
if(indev_type == LV_INDEV_TYPE_KEYPAD ||
|
||||
(indev_type == LV_INDEV_TYPE_ENCODER && lv_group_get_editing(lv_obj_get_group(tabview))))
|
||||
{
|
||||
lv_obj_send_event(ext->btns, LV_EVENT_CLICKED);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROLL) {
|
||||
/* The button matrix is not in a group (the tab view is in it) but it should handle the group signals.
|
||||
* So propagate the related signals to the button matrix manually*/
|
||||
if(ext->btns) {
|
||||
ext->btns->signal_cb(ext->btns, sign, param);
|
||||
}
|
||||
|
||||
if(sign == LV_SIGNAL_CONTROLL) {
|
||||
/*Simulate a click when enter is pressed*/
|
||||
char c = *((char *)param);
|
||||
if(c == LV_GROUP_KEY_ENTER) {
|
||||
lv_obj_send_event(ext->btns, LV_EVENT_CLICKED);
|
||||
}
|
||||
}
|
||||
else if(sign == LV_SIGNAL_FOCUS) {
|
||||
if(sign == LV_SIGNAL_FOCUS) {
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
/*With ENCODER select the first button only in edit mode*/
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
|
||||
Reference in New Issue
Block a user