fltk::NumericInput Class Reference

Inherits fltk::Input.

Inherited by fltk::FloatInput.

List of all members.

Public Member Functions

int handle (int)
void value (int)
void value (double)

Protected Member Functions

int handle_arrow (int)

Detailed Description

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
(310)314-2800 FAX(310)314-2888


Member Function Documentation

int NumericInput::handle ( int  event) [virtual]

Does the up/down arrows and mouse wheel. Alt+drag also adjusts the value. All other points are sent to the Input base class.

Reimplemented from fltk::Input.

int NumericInput::handle_arrow ( int  dir) [protected]

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.

void NumericInput::value ( int  v)

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.

void NumericInput::value ( double  A)

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.


The documentation for this class was generated from the following files: