Programmer Reference : Extended Widgets : Spin button widget
Spin button widget
A spin button (EwSpinButton) provides an interface for selecting a single value from a collection of strings or a range of numbers. The widget consists of an entry field that displays the current value and two arrow buttons that you can use to scroll forward and backward through the values. You can also scroll through the values using the up and down arrow keys on the keyboard. The value in the text entry field can be edited directly if the editable resource is set to true. Following is an example of a spin button widget:
Spin button
The itemType resource specifies whether the spin button is to display numeric data or a collection of strings. Possible values for this resource are as follows:
XmSBNUMERIC
The spin button holds numeric data
XmSBSTRING
The spin button holds a collection of strings
The minimum, maximum, and increment resources can be used to define the range values for a numeric spin button. These resources are ignored for spin buttons that hold collections of strings.
EwSpinButton also provides several callbacks for application interaction. Callback protocol is available for gaining and losing focus (focusCallback and losingFocusCallback), incrementing and decrementing the current value (incrementCallback and decrementCallback), and activation of the default button (activateCallback). A less specific callback is provided for any change to the current value (valueChangedCallback). An additional callback is provided to indicate that the value in the entry field has been edited by users (modifyVerifyCallback).
The following method creates a spin button that traverses the days of the week. Add this method to a class using the pool dictionaries CwConstants and EwConstants.
spinButtonExample
| spinButton shell |
shell := CwTopLevelShell
createApplicationShell: 'shell'
argBlock: [:w | w
title: 'SpinButton Example';
width: 110;
height: 30].
spinButton:= shell
createSpinButton: 'spinButton'
argBlock: [:w | w
itemType: 2; "Or XmSBSTRING instead of 2"
items: #('Monday' 'Tuesday' 'Wednesday' 'Thursday'
'Friday' 'Saturday' 'Sunday');
wrap: true].
spinButton manageChild.
shell realizeWidget
When you run the method by evaluating <class name> new spinButtonExample, you get the following:

Spin button
Last modified date: 08/22/2024