Search documentation of wx

# wxSpinCtrl (wx v2.4.3.1)

View Source

`wxSpinCtrl` combines `wxTextCtrl` and `wxSpinButton` in one control.

## Styles

This class supports the following styles:

- wxSP_ARROW_KEYS: The user can use arrow keys to change the value.

- wxSP_WRAP: The value wraps at the minimum and maximum.

- wxTE_PROCESS_ENTER: Indicates that the control should generate `wxEVT_TEXT_ENTER` events. Using this style will prevent the user from using the Enter key for dialog navigation (e.g. activating the default button in the dialog) under MSW.

- wxALIGN_LEFT: Same as wxTE_LEFT for `wxTextCtrl`: the text is left aligned (this is the default).

- wxALIGN_CENTRE_HORIZONTAL: Same as wxTE_CENTRE for `wxTextCtrl`: the text is centered.

- wxALIGN_RIGHT: Same as wxTE_RIGHT for `wxTextCtrl`: the text is right aligned.

See:

- `wxSpinButton`

- `wxControl`

This class is derived, and can use functions, from:

- `wxControl`

- `wxWindow`

- `wxEvtHandler`

wxWidgets docs: wxSpinCtrl

## Events

Event types emitted from this class:

- `command_spinctrl_updated`

# Summary

## Types

wxSpinCtrl()

## Functions

create(This, Parent)

Equivalent to `create(This, Parent, [])`.

create/3

Creation function called by the spin control constructor.

destroy(This)

Destroys the object

getMax(This)

Gets maximal allowable value.

getMin(This)

Gets minimal allowable value.

getValue(This)

Gets the value of the spin control.

new()

Default constructor.

new(Parent)

Equivalent to `new(Parent, [])`.

new/2

Constructor, creating and showing a spin control.

setRange(This, MinVal, MaxVal)

Sets range of allowable values.

setSelection(This, From, To)

Select the text in the text part of the control between positions `from` (inclusive) and `to` (exclusive).

setValue/2

Sets the value of the spin control.

# Types

# wxSpinCtrl()

    -type wxSpinCtrl() :: wx:wx_object().

# Functions

# create(This, Parent)

    -spec create(This, Parent) -> boolean() when This :: wxSpinCtrl(), Parent :: wxWindow:wxWindow().

Equivalent to `create(This, Parent, [])`.

# create/3

    -spec create(This, Parent, [Option]) -> boolean()
                    when
                        This :: wxSpinCtrl(),
                        Parent :: wxWindow:wxWindow(),
                        Option ::
                            {id, integer()} |
                            {value, unicode:chardata()} |
                            {pos, {X :: integer(), Y :: integer()}} |
                            {size, {W :: integer(), H :: integer()}} |
                            {style, integer()} |
                            {min, integer()} |
                            {max, integer()} |
                            {initial, integer()}.

Creation function called by the spin control constructor.

See `new/2` for details.

# destroy(This)

    -spec destroy(This :: wxSpinCtrl()) -> ok.

Destroys the object

# getMax(This)

    -spec getMax(This) -> integer() when This :: wxSpinCtrl().

Gets maximal allowable value.

# getMin(This)

    -spec getMin(This) -> integer() when This :: wxSpinCtrl().

Gets minimal allowable value.

# getValue(This)

    -spec getValue(This) -> integer() when This :: wxSpinCtrl().

Gets the value of the spin control.

# new()

    -spec new() -> wxSpinCtrl().

Default constructor.

# new(Parent)

    -spec new(Parent) -> wxSpinCtrl() when Parent :: wxWindow:wxWindow().

Equivalent to `new(Parent, [])`.

# new/2

    -spec new(Parent, [Option]) -> wxSpinCtrl()
                 when
                     Parent :: wxWindow:wxWindow(),
                     Option ::
                         {id, integer()} |
                         {value, unicode:chardata()} |
                         {pos, {X :: integer(), Y :: integer()}} |
                         {size, {W :: integer(), H :: integer()}} |
                         {style, integer()} |
                         {min, integer()} |
                         {max, integer()} |
                         {initial, integer()}.

Constructor, creating and showing a spin control.

If `value` is non-empty, it will be shown in the text entry part of the control and if it has numeric value, the initial numeric value of the control, as returned by `getValue/1` will also be determined by it instead of by `initial`. Hence, it only makes sense to specify `initial` if `value` is an empty string or is not convertible to a number, otherwise `initial` is simply ignored and the number specified by `value` is used.

See: `create/3`

# setRange(This, MinVal, MaxVal)

    -spec setRange(This, MinVal, MaxVal) -> ok
                      when This :: wxSpinCtrl(), MinVal :: integer(), MaxVal :: integer().

Sets range of allowable values.

Notice that calling this method may change the value of the control if it's not inside the new valid range, e.g. it will become `minVal` if it is less than it now. However no `wxEVT_SPINCTRL` event is generated, even if it the value does change.

Note: Setting a range including negative values is silently ignored if current base is set to 16.

# setSelection(This, From, To)

    -spec setSelection(This, From, To) -> ok when This :: wxSpinCtrl(), From :: integer(), To :: integer().

Select the text in the text part of the control between positions `from` (inclusive) and `to` (exclusive).

This is similar to `wxTextCtrl:setSelection/3`.

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

# setValue/2

    -spec setValue(This, Value) -> ok when This :: wxSpinCtrl(), Value :: integer();
                  (This, Text) -> ok when This :: wxSpinCtrl(), Text :: unicode:chardata().

Sets the value of the spin control.

It is recommended to use the overload taking an integer value instead.

Notice that, unlike `wxTextCtrl:setValue/2`, but like most of the other setter methods in wxWidgets, calling this method does not generate any events as events are only generated for the user actions.