wxRuby Documentation Home

# Wx::SpinCtrl

SpinCtrl combines TextCtrl and
SpinButton in one control.

## Derived from

Control

Window

EvtHandler

Object

## Window styles

`SP_ARROW_KEYS` | The user can use arrow keys to change the value.
`SP_WRAP` | The value wraps at the minimum and maximum.

## Event handling

To process input from a spin button, use one of these event handler macros to direct input to member
functions that take a SpinEvent argument:

evt_spinctrl(id) { | event | … } | Generated whenever the numeric valueof the spinctrl is updated

You may also use the SpinButton event macros, however
the corresponding events will not be generated under all platforms. Finally, if
the user modifies the text in the edit part of the spin control directly, the
`EVT_TEXT` is generated, like for the TextCtrl.

When the use enters text into the text area, the text is not
validated until the control loses focus (e.g. by using the TAB
key). The value is then adjusted to the range and a
SpinEvent sent then if the value
is different from the last value sent.

## See also

Event handling overview,
SpinButton,
Control

## Methods

- SpinCtrl.new
- SpinCtrl#create
- SpinCtrl#set_value
- SpinCtrl#get_value
- SpinCtrl#set_range
- SpinCtrl#set_selection
- SpinCtrl#get_min
- SpinCtrl#get_max

### SpinCtrl.new

SpinCtrl.new(%(arg-type)Window% parent, Integer id = -1, String value = ’’, Point pos = DEFAULT_POSITION, Size size = DEFAULT_SIZE, Integer style = SP_ARROW_KEYS, Integer min = 0, Integer max = 100, Integer initial = 0, String name = _T(“SpinCtrl”))

Constructor, creating and showing a spin control.

#### Parameters

- parent Parent window. Must not be NULL.
- value Default value.
- id Window identifier. A value of -1 indicates a default value.
- pos Window position. If the position (-1, -1) is specified then a default position is chosen.
- size Window size. If the default size (-1, -1) is specified then a default size is chosen.
- style Window style. See SpinButton.
- min Minimal value.
- max Maximal value.
- initial Initial value.
- name Window name.

#### See also

SpinCtrl#create

### SpinCtrl#create

Boolean create(%(arg-type)Window% parent, Integer id = -1, String value = ’’, Point pos = DEFAULT_POSITION, Size size = DEFAULT_SIZE, Integer style = SP_ARROW_KEYS, Integer min = 0, Integer max = 100, Integer initial = 0, String name = _T(“SpinCtrl”))

Creation function called by the spin control constructor.

See SpinCtrl.new for details.

### SpinCtrl#set_value

set_value(%(arg-type)String% text) set_value(%(arg-type)Integer% value)

Sets the value of the spin control.

### SpinCtrl#get_value

Integer get_value()

Gets the value of the spin control.

### SpinCtrl#set_range

set_range(%(arg-type)Integer% minVal, Integer maxVal)

Sets range of allowable values.

### SpinCtrl#set_selection

set_selection(%(arg-type)Integer% from, Integer to)

Select the text in the text part of the control between positions
from (inclusive) and to (exclusive). This is similar to
TextCtrl#set_selection.

NB: this is currently only implemented for Windows and generic versions
of the control.

### SpinCtrl#get_min

Integer get_min()

Gets minimal allowable value.

### SpinCtrl#get_max

Integer get_max()

Gets maximal allowable value.

[This page automatically generated from the Textile source at 2023-06-09 00:45:32 +0000]