summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2006-12-08 04:41:52 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2006-12-08 04:41:52 +0000
commitd168950719cfebaa6d0296aed1617e26ff8e7ed9 (patch)
treedeaac5ee87869c75bb8bbf2440215b1746d0fef2
parent9c9cb4bfdea5ed1ef92d357e0479361c0f007268 (diff)
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
-rw-r--r--FL/Fl_Spinner.H11
1 files changed, 8 insertions, 3 deletions
diff --git a/FL/Fl_Spinner.H b/FL/Fl_Spinner.H
index 662ae8cb8..9f76ad73e 100644
--- a/FL/Fl_Spinner.H
+++ b/FL/Fl_Spinner.H
@@ -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());
}