forked from enlightenment/efl
efl_ui_spin_button: Fix can't input number in case of the min value is bigger than 1.
Summary: Min Max validate logic has been changed to support decimal point counting. It makes this side effect. Test Plan: elementary_test -> efl_ui_spin_button sample. (On the min max filter enabled.) Reviewers: jpeg, Jaehyun_Cho, woohyun Reviewed By: Jaehyun_Cho Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D5580
This commit is contained in:
parent
7ae1030383
commit
845d6d1b57
|
@ -285,7 +285,7 @@ _min_max_validity_filter(void *data, Evas_Object *obj, char **text)
|
||||||
const char *str, *point;
|
const char *str, *point;
|
||||||
char *insert, *new_str = NULL;
|
char *insert, *new_str = NULL;
|
||||||
double val;
|
double val;
|
||||||
int max_len, len;
|
int max_len = 0, len;
|
||||||
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN(data);
|
EINA_SAFETY_ON_NULL_RETURN(data);
|
||||||
EINA_SAFETY_ON_NULL_RETURN(obj);
|
EINA_SAFETY_ON_NULL_RETURN(obj);
|
||||||
|
@ -299,15 +299,9 @@ _min_max_validity_filter(void *data, Evas_Object *obj, char **text)
|
||||||
insert = *text;
|
insert = *text;
|
||||||
new_str = _text_insert(str, insert, elm_entry_cursor_pos_get(obj));
|
new_str = _text_insert(str, insert, elm_entry_cursor_pos_get(obj));
|
||||||
if (!new_str) return;
|
if (!new_str) return;
|
||||||
max_len = log10(fabs(pd->val_max)) + 1;
|
if (strchr(new_str, '-')) max_len++;
|
||||||
|
|
||||||
new_str = _text_insert(str, insert, elm_entry_cursor_pos_get(obj));
|
if (pd->format_type == SPIN_FORMAT_FLOAT)
|
||||||
if (pd->format_type == SPIN_FORMAT_INT)
|
|
||||||
{
|
|
||||||
len = strlen(new_str);
|
|
||||||
if (len < max_len) goto end;
|
|
||||||
}
|
|
||||||
else if (pd->format_type == SPIN_FORMAT_FLOAT)
|
|
||||||
{
|
{
|
||||||
point = strchr(new_str, '.');
|
point = strchr(new_str, '.');
|
||||||
if (point)
|
if (point)
|
||||||
|
@ -320,6 +314,11 @@ _min_max_validity_filter(void *data, Evas_Object *obj, char **text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
max_len += (fabs(pd->val_max) > fabs(pd->val_min)) ?
|
||||||
|
(log10(fabs(pd->val_max)) + 1) : (log10(fabs(pd->val_min)) + 1);
|
||||||
|
len = strlen(new_str);
|
||||||
|
if (len < max_len) goto end;
|
||||||
|
|
||||||
val = strtod(new_str, NULL);
|
val = strtod(new_str, NULL);
|
||||||
if ((val < pd->val_min) || (val > pd->val_max))
|
if ((val < pd->val_min) || (val > pd->val_max))
|
||||||
*insert = 0;
|
*insert = 0;
|
||||||
|
|
Loading…
Reference in New Issue