NumericVBT
is a VBT class for displaying and changing an integer
in some range.
It has a type-in field which is restricted to a given range of integers.
It also has two buttons that step up and down the value.
It has a callback method which is called each time the value
in the type-in field is changed, either by typing in and pressing carriage
return, or by clicking on the plus and minus buttons.
By subclassing the callback method it is possible to do something
in response to any user change to the numeric value.
The program
Numeric.m3
illustrates
the use of a NumericVBT
.
This program displays a NumericVBT
along with three additional
buttons that set the
type-in field to be empty, set the minimum value and the maximum values.
It also uses a text field along the bottom of the window
which is used to display whether the callback
has been called in response to a mouse click in the ``+'' button
or the ``-'' button, or to a carriage return.
The images
Numeric
in action.
Initially, the NumericVBT
has no value
and will accept any value between the smallest integer and the largest integer.
Clicking the mouse in empty, middle field results in the blinking cursor
indicating that the a value can be entered.
The user then enters a number.
Only digits are acceptable to the numeric field.
After entering 345 the user presses the return key.
The current value of the NumericVBT
can be changed by pressing
the box with the ``+'' or the ``-'' in it.
Holding down the mouse button while in the ``+'' box will increase
the value until the button is released or the maximum is reached.
The current value in the NumericVBT
can be made the maximum
value by pressing the ``Set Max'' button.
The ``Set Empty'' button sets the current numeric value to be undefined.
The function call NumericVBT.IsEmpty
returns true if the current value is undefined;
if the current value is a valid integer, then it returns false.