On 06/20/11 10:55, Daniel wrote:
>> Just wondering: why try to feedback the value of the input field
>> to itself?
> The reason: making app for people who will not know what
> octal base is, so they will think that if the input says
> 08 it is equal to 8(decimal).
But I think that feedback loop is actually /causing/
the problem. By feeding back, the value defaults to "0"
which always ends up becoming a prefix.
I've never used the Fl_Value_Input widget myself because
it never seemed to do what I wanted; the dragging behavior
seemed weird (a carry over from the now ancient FORMS library?)
and was never adopted. Most folks wanting this would use
a slider attached to an input widget.
I think this widget is showing its age.
> Questions:
> 1. Does the Fl_Value_Input have function type(); - didnt find it in the
> documentation, not for Fl_Value_Input neither for Fl_Valuator.
It does, but I *think* you might want to use Fl_Int_Input instead,
which sets the type() to FL_INT_INPUT. ie. using the higher level
classes is the way to set the type(), instead of setting the type().
(I think that's why type() is undocumented).
Here is code that does what I think you might want:
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Int_Input.H>
Fl_Int_Input *my_input=(Fl_Int_Input *)0;
void modify_value(Fl_Int_Input *, void*) {
int i;
if ( sscanf(my_input->value(), "%d", &i) == 1 ) {
fprintf(stderr, "CALLBACK CALLED, VALUE=%d\n", i);
}
}
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_Int_Input(25, 25, 100, 25);
my_input->when(FL_WHEN_CHANGED);
my_input->callback((Fl_Callback*)modify_value);
} // Fl_Int_Input* my_input
o->end();
} // Fl_Double_Window* o
w->show(argc, argv);
return Fl::run();
}
..this technique also doesn't have the 'dragging' behavior
described above, acting like a 'normal' integer input widget.
> 2. What to include for accessing FL_DECIMAL_INT_INPUT constant, didnt find it
> in doc either.
Actually, that was a suggestion on my part to improve the lib,
not something that's actually implemented.
But I'm not familiar enough with the widget to know if there's
a better way of using it. I never use it myself.
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs