From d168950719cfebaa6d0296aed1617e26ff8e7ed9 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Fri, 8 Dec 2006 04:41:52 +0000 Subject: 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 --- FL/Fl_Spinner.H | 11 ++++++++--- 1 file 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()); } -- cgit v1.2.3