mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
lv_textarea fix cursor alignment with empty textarea when the text alignment is center or right
This commit is contained in:
parent
42f79763e1
commit
63aba1b3de
@ -572,10 +572,21 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint32_t char_id, lv_point_
|
||||
LV_ASSERT_NULL(pos);
|
||||
|
||||
const char * txt = lv_label_get_text(label);
|
||||
lv_label_align_t align = lv_label_get_align(label);
|
||||
|
||||
if(txt[0] == '\0') {
|
||||
pos->x = 0;
|
||||
pos->y = 0;
|
||||
switch(align) {
|
||||
case LV_LABEL_ALIGN_LEFT:
|
||||
pos->x = 0;
|
||||
break;
|
||||
case LV_LABEL_ALIGN_RIGHT:
|
||||
pos->x = lv_obj_get_width(label);
|
||||
break;
|
||||
case LV_LABEL_ALIGN_CENTER:
|
||||
pos->x = lv_obj_get_width(label) / 2;
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -597,7 +608,6 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint32_t char_id, lv_point_
|
||||
if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND;
|
||||
if(ext->long_mode == LV_LABEL_LONG_EXPAND) flag |= LV_TXT_FLAG_FIT;
|
||||
|
||||
lv_label_align_t align = lv_label_get_align(label);
|
||||
if(align == LV_LABEL_ALIGN_CENTER) flag |= LV_TXT_FLAG_CENTER;
|
||||
if(align == LV_LABEL_ALIGN_RIGHT) flag |= LV_TXT_FLAG_RIGHT;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user