ta click: add to lv_ta_signal too
This commit is contained in:
@@ -1091,6 +1091,30 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if(sign == LV_SIGNAL_PRESSED) {
|
||||
lv_indev_t * indev = (lv_indev_t *)param;
|
||||
lv_area_t label_coords;
|
||||
uint16_t index_of_char_at_position;
|
||||
|
||||
lv_obj_get_coords(ext->label, &label_coords);
|
||||
|
||||
lv_point_t relative_position;
|
||||
relative_position.x = indev->proc.act_point.x - label_coords.x1;
|
||||
relative_position.y = indev->proc.act_point.y - label_coords.y1;
|
||||
|
||||
lv_coord_t label_width = lv_obj_get_width(ext->label);
|
||||
|
||||
/*Check if the click happened on the left side of the area outside the label*/
|
||||
if (relative_position.x < label_width / 2) {
|
||||
index_of_char_at_position = 0;
|
||||
}
|
||||
/*Check if the click happened on the right side of the area outside the label*/
|
||||
else if (relative_position.x >= label_width / 2) {
|
||||
index_of_char_at_position = LV_TA_CURSOR_LAST;
|
||||
}
|
||||
|
||||
lv_ta_set_cursor_pos(ta, index_of_char_at_position);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1124,18 +1148,18 @@ static lv_res_t lv_ta_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void
|
||||
|
||||
lv_obj_get_coords(ext->label, &label_coords);
|
||||
|
||||
lv_point_t relative_position = {
|
||||
indev->proc.act_point.x - label_coords.x1,
|
||||
indev->proc.act_point.y - label_coords.y1
|
||||
};
|
||||
lv_point_t relative_position;
|
||||
relative_position.x = indev->proc.act_point.x - label_coords.x1;
|
||||
relative_position.y = indev->proc.act_point.y - label_coords.y1;
|
||||
|
||||
|
||||
lv_coord_t label_width = lv_obj_get_width(ext->label);
|
||||
|
||||
/*Check if the click happend on the left side of the area ouside the label*/
|
||||
/*Check if the click happened on the left side of the area outside the label*/
|
||||
if (relative_position.x < 0) {
|
||||
index_of_char_at_position = 0;
|
||||
}
|
||||
/*Check if the click happend on the right side of the area ouside the label*/
|
||||
/*Check if the click happened on the right side of the area outside the label*/
|
||||
else if (relative_position.x >= label_width) {
|
||||
index_of_char_at_position = LV_TA_CURSOR_LAST;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user