Domingo Alvarez Duarte wrote:
>> It seems a bit logical to have methods to get/set value on then
>> with the respective type, this way we save a lot of work for the
>> users that doesn't need to make conversions to and from then.

Greg:
>  Since the Fl_Int_Input and Fl_Float_Input classes are implemented
>  as .H files only, I'd offer that the methods be made available
>  in Fl_Input_, since there's no reason floats and ints shouldn't
>  be accessible to the float, int, and string version of the widget.
>
>  For the 'get' methods, I strongly suggest we provide a way
>  for FLTK to return an error if the value in the widget cannot
>  be converted.
>
>  One way could be to add a fail() method the caller can check, eg:
>
>    Fl_Input *in;
>    [..]
>    int val = in->value_int(); // get value as an integer
>    if ( in->fail() ) {                // check for conversion error
>      printf("'%s' is not an integer.", in->value());
>    }

Such decoding methods should check for trailing crud so that 0x01x1
would trigger fail() too. I've tried to subclass to have validating
input fields before, and once you take cut'n'paste into account there
are points when the field can be invalid...

D.

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to