Inherited by fltk::FloatInput.
The fltk::NumericInput class is a subclass of fltk::Input that redefines the up and down arrow keys to increment and decrement the digit of the number to the right of the cursor. This makes it very easy to edit numbers.
If you change when() to fltk::WHEN_ENTER_KEY the callback is only done when the user hits the up/down arrow keys or when the user types the Enter key. This may be more useful than the default setting of fltk::WHEN_CHANGED which can make the callback happen when partially-edited numbers are in the field.
This version lets the user type any text into the field. This is useful if you run the text through an expression parser so the user can type in math expressions. However if you want to limit the input to text that can be run through strtol() or strtod() you should use the subclasses fltk::IntInput or fltk::FloatInput.
When you construct the widget the text starts out blank. You may want to set it with value(0) or something.
This user interface design is Copyright (C) 2000-2003 Digital Domain. Patent Pending!
License is ONLY granted to implement this algorithim as GPL, LGPL, or FLTK licensed code. Note that by using fltk you may use this in a closed-source program.
License to use this technology in other cases may be available:
D2 Software / Digital Domain
300 Rose Avenue, Venice, CA 90291, USA
Do the work of up-arrow (if direction is greater than zero) or down-arrow if direction is less than zero. This protected method is available so subclasses can change what keys do this, or invert the direction of the arrows.
Does a %d sprintf of the value and uses the result to set the string value. Notice that there is no inverse function, you will have to call strtol(widget->text(),0,0) yourself.
Does a %g sprintf of the value and uses the result to set the string value. Notice that there is no inverse function, you will have to call strtod(widget->value(),0,0) yourself.