BTW, to report bugs, we now use the STR system to keep track
        of bugs instead of posting to fltk.bugs. Go to the main fltk.org page
        and click on: Bugs & Features -> Submit Bug or Feature Request

        Direct link:
        http://fltk.org/str.php

> Here i noticed that if the value_input would say 01..07
> it was equal to the value 1..7. All good that far but if
> you enter 08 or 09 the value will still be 0 if you read it

        This sounds like octal behavior, due to the leading zero.

        Fl_Value_Input internally uses strtol() to parse input,
        and the docs for strtol indicate it can parse octal and hex
        in the usual fashion (leading '0' == octal, leading '0x' == hex)

        For instance, in your program if you type:

                77<left-arrow><left-arrow>0

        ..you'll get 63 (octal 077).

        Also: if you comment out the code in the callback that
        sets the value(), and just print it, you can type in things
        like:

                0x80 -> 128
                0xffff -> 65535

        ..etc.

        For this reason, it's unsafe to assume a leading zero
        will be ignored.

        (The fact Fl_Value_Input uses strtol() should probably be documented,
        as it seems relevant. I'd suggest posting an STR to have the 
Fl_Value_Input
        docs cover the internal use of strtol(), and the caveats that includes)

        Just wondering: why try to feedback the value of the input field
        to itself? Perhaps this is just to demonstrate the problem, but
        in actual programming, I wouldn't think you'd want to do it,
        as the input field manages itself.

        Perhaps this widget should let the app pick specific encoding
        formats, eg:

                type(FL_DECIMAL_INT_INPUT);     // decimal input only
                type(FL_OCTAL_INT_INPUT);       // only allow octal
                type(FL_HEX_INT_INPUT);         // only allow hex

        ..and reserve the FL_INT_INPUT for the current behavior
        (for backwards compatibility).

        BTW, to get that code to compile, I replaced:

#include "input_field_ex.h"

        ..with:

#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Value_Input.H>


On 06/19/11 06:18, Daniel wrote:
> I made a callback function for an value_input field so that the beginning 0 
> was to disapere when an other value was entered.
> 
> Here i noticed that if the value_input would say 01..07 it was equal to the 
> value 1..7. All good that far but if you enter 08 or 09 the value will still 
> be 0 if you read it and also the callback function wont be called.
> 
> Simple example code:
> 
> 
> 
> #include "input_field_ex.h"
> 
> Fl_Value_Input *my_input=(Fl_Value_Input *)0;
> 
> void modify_value(Fl_Value_Input*, void*){
>       int a= my_input->value();
>       my_input->value(1);//Trick compiler to not opimize code 
> value(value(my_input))
>       my_input->value(2);// trick compiler cont.
>       my_input->value(a);
> }
> 
> int main(int argc, char **argv) {
>   Fl_Double_Window* w;
>   { Fl_Double_Window* o = new Fl_Double_Window(475, 268);
>     w = o;
>     { my_input = new Fl_Value_Input(25, 25, 25, 25);
>       my_input->maximum(50000);
>       my_input->step(1);
>       my_input->callback((Fl_Callback*)modify_value);
>     } // Fl_Value_Input* my_input
>     o->end();
>   } // Fl_Double_Window* o
>   w->show(argc, argv);
>   return Fl::run();
> }
> 
> 
> Here default value is 0, enter 1 or 2 or .. 7 you will only see 7. Enter 8 or 
> 9 you will see 08 or 09. If you make an alert in the callback function you 
> will see that it doesnt even get called for the last 2 cases.
> 
> 
> 

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

Reply via email to