From 9f978cb0875e553628cba4ce3cc75dd26fe5b35c Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Fri, 20 Sep 2019 16:31:12 +0200 Subject: [PATCH] lv_ta: copy fixes --- src/lv_objx/lv_ta.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/lv_objx/lv_ta.c b/src/lv_objx/lv_ta.c index 98fdfbac1..fa44a105c 100644 --- a/src/lv_objx/lv_ta.c +++ b/src/lv_objx/lv_ta.c @@ -162,6 +162,23 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy) ext->cursor.pos = copy_ext->cursor.pos; ext->cursor.valid_x = copy_ext->cursor.valid_x; ext->cursor.type = copy_ext->cursor.type; + + if(ext->pwd_mode != 0) pwd_char_hider( new_ta); + + if(copy_ext->placeholder != NULL) + ext->placeholder = lv_label_create(new_ta, copy_ext->placeholder); + else + ext->placeholder = NULL; + + if(copy_ext->pwd_tmp) { + uint16_t len = lv_mem_get_size(copy_ext->pwd_tmp); + ext->pwd_tmp = lv_mem_alloc(len); + lv_mem_assert(ext->pwd_tmp); + if(ext->pwd_tmp == NULL) return NULL; + + memcpy(ext->pwd_tmp, copy_ext->pwd_tmp, len); + } + if(copy_ext->one_line) lv_ta_set_one_line(new_ta, true); lv_ta_set_style(new_ta, LV_TA_STYLE_CURSOR, lv_ta_get_style(copy, LV_TA_STYLE_CURSOR)); @@ -652,7 +669,8 @@ void lv_ta_set_pwd_mode(lv_obj_t * ta, bool en) strcpy(ext->pwd_tmp, txt); uint16_t i; - for(i = 0; i < len; i++) { + uint16_t encoded_len = lv_txt_get_encoded_length(txt); + for(i = 0; i < encoded_len; i++) { txt[i] = '*'; /*All char to '*'*/ } txt[i] = '\0';