fix(textarea): fix max length handling

This commit is contained in:
Gabor Kiss-Vamosi
2022-03-24 18:48:25 +01:00
parent 15247f9305
commit 127d8e82e3

View File

@@ -963,19 +963,13 @@ static bool char_is_accepted(lv_obj_t * obj, uint32_t c)
{
lv_textarea_t * ta = (lv_textarea_t *)obj;
/*If the accepted char list in not specified the accept the character*/
if(ta->accepted_chars == NULL) return true;
/*If no restriction accept it*/
if((ta->accepted_chars == NULL || ta->accepted_chars[0] == '\0') && ta->max_length == 0) return true;
/*Too many characters?*/
if(ta->max_length > 0 && _lv_txt_get_encoded_length(lv_textarea_get_text(obj)) >= ta->max_length) {
return false;
}
if(ta->accepted_chars == NULL || ta->accepted_chars[0] == '\0') return true;
/*Accepted character?*/
/*We're sure ta->accepted_chars != NULL*/
uint32_t i = 0;
while(ta->accepted_chars[i] != '\0') {