spinner: just set the value if conversion to float worked, otherwise ignore it.

Instead of using atof() and always getting a value (even if 0 when
invalid), check if conversion to float worked and if not just revert
to last value, ignoring the input.

I'm being quite tolerant here, allowing spaces at end.



SVN revision: 45632
This commit is contained in:
Gustavo Sverzut Barbieri 2010-01-27 19:34:45 +00:00
parent 2f71270e54
commit 108da05a3a
1 changed files with 8 additions and 1 deletions

View File

@ -1,5 +1,6 @@
#include <Elementary.h>
#include "elm_priv.h"
#include <ctype.h>
/**
* @defgroup Spinner
@ -233,11 +234,17 @@ static void
_apply_entry_value(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
const char *str;
char *end;
double val;
if (!wd) return;
_hide_entry(obj);
val = atof(elm_entry_entry_get(wd->ent));
str = elm_entry_entry_get(wd->ent);
if (!str) return;
val = strtod(str, &end);
if ((*end != '\0') && (!isspace(*end))) return;
elm_spinner_value_set(obj, val);
}