mirror of
https://github.com/fltk/fltk.git
synced 2025-12-16 01:26:37 +08:00
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:
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user