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

Add lv_ta_clear_selection and fix a few bugs

This commit is contained in:
Themba Dube 2019-03-27 17:22:44 -04:00
parent b14ed6288a
commit 0a4e8979ec
2 changed files with 26 additions and 0 deletions

View File

@ -431,6 +431,9 @@ void lv_ta_set_text(lv_obj_t * ta, const char * txt)
{
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
/*Clear the existing selection*/
lv_ta_clear_selection(ta);
/*Add the character one-by-one if not all characters are accepted or there is character limit.*/
if(lv_ta_get_accepted_chars(ta) || lv_ta_get_max_length(ta)) {
lv_label_set_text(ext->label, "");
@ -626,10 +629,13 @@ void lv_ta_set_pwd_mode(lv_obj_t * ta, bool en)
}
txt[i] = '\0';
lv_ta_clear_selection(ta);
lv_label_set_text(ext->label, NULL);
}
/*Pwd mode is now disabled*/
else if(ext->pwd_mode == 1 && en == false) {
lv_ta_clear_selection(ta);
lv_label_set_text(ext->label, ext->pwd_tmp);
lv_mem_free(ext->pwd_tmp);
ext->pwd_tmp = NULL;
@ -963,6 +969,20 @@ void lv_ta_get_selection(lv_obj_t * ta, int * sel_start, int * sel_end) {
* Other functions
*====================*/
/**
* Clear the selection on the text area.
* @param ta Text area object
*/
void lv_ta_clear_selection(lv_obj_t * ta) {
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
lv_label_ext_t * ext_label = lv_obj_get_ext_attr(ext->label);
ext_label->selection_start = -1;
ext_label->selection_end = -1;
lv_obj_invalidate(ta);
}
/**
* Move the cursor one character right
* @param ta pointer to a text area object

View File

@ -379,6 +379,12 @@ void lv_ta_get_selection(lv_obj_t * ta, int * sel_start, int * sel_end);
* Other functions
*====================*/
/**
* Clear the selection on the text area.
* @param ta Text area object
*/
void lv_ta_clear_selection(lv_obj_t * ta);
/**
* Move the cursor one character right
* @param ta pointer to a text area object