Don't range check typed numbers until the user presses enter or leaves

the spinner.

Set the input field to floating point mode for non-integer steps.

Use %g as the default format.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5555 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet
2006-12-08 04:41:52 +00:00
parent 9c9cb4bfde
commit d168950719

View File

@@ -126,13 +126,13 @@ class Fl_Spinner : public Fl_Group
minimum_ = 1.0;
maximum_ = 100.0;
step_ = 1.0;
format_ = "%.0f";
format_ = "%g";
align(FL_ALIGN_LEFT);
input_.value("1");
input_.type(FL_INT_INPUT);
input_.when(FL_WHEN_CHANGED);
input_.when(FL_WHEN_ENTER_KEY | FL_WHEN_RELEASE);
input_.callback((Fl_Callback *)sb_cb, this);
up_button_.callback((Fl_Callback *)sb_cb, this);
@@ -180,7 +180,12 @@ class Fl_Spinner : public Fl_Group
H / 2 + 2, H / 2);
}
double step() const { return (step_); }
void step(double s) { step_ = s; update(); }
void step(double s) {
step_ = s;
if (step_ != (int)step_) input_.type(FL_FLOAT_INPUT);
else input_.type(FL_INT_INPUT);
update();
}
Fl_Color textcolor() const {
return (input_.textcolor());
}