Inherits fltk::NumericInput.
Inherited by fltk::IntInput.
Public Member Functions | |
double | fvalue () const |
long | lvalue () const |
Private Member Functions | |
virtual bool | replace (int, int, const char *, int) |
A subclass of NumericInput that only allows the user to type floating point numbers (sign, digits, decimal point, more digits, 'E' or 'e', sign, digits), or hex constants that start with "0x". This is done by overriding the replace() method. Besides editing the text the user can use the up/down arrow keys to change the digits.
You may want a ValueInput widget instead. It has up/down buttons (what is called a "Spinner" in some toolkits).
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.
The type() can either be either FloatInput::FLOAT or FloatInput::INT. Setting it to INT makes this act like the IntInput subclass.
double FloatInput::fvalue | ( | ) | const |
Convert the string to a double using strtod()
long FloatInput::lvalue | ( | ) | const |
FloatInput::ivalue() const Convert the string to an integer, using int(strtol())
Convert the string to a long using strtol()
bool FloatInput::replace | ( | int | b, |
int | e, | ||
const char * | text, | ||
int | ilen | ||
) | [private, virtual] |
This call does all editing of the text. It deletes the region between b and e (either one may be less or equal to the other), and then inserts ilen (which may be zero) characters from the string text at that point and leaves the mark() and position() after the insertion. If the text is changed the callback is done if the when() flags indicate it should be done.
Subclasses of Input can override this method to control what characters can be inserted into the text. A typical implementation will check the characters in the insertion for legality and then call Input::replace() only if they are all ok.
b and e are bounds checked so don't worry about sending values outside the length of the string.
Subclasses should return true if the keystroke that produced this call should be "eaten". If false is returned the keystroke is allowed to be tested as a shortcut for other widgets. In our experience it is best to return true even if you don't make changes. The base class version returns true always.
Reimplemented from fltk::Input.