Spinner

Component that can hold a number, list items, date/time, and IP addresses. Iterate through numbers or list items with up and down buttons or up and down keys (when Spinner has focus).

Constructor

new Spinner(type, list_or_formatopt, minopt, maxopt, stepopt)

Creates a new Spinner component for selecting numbers, list items, dates/times, or IP addresses.

Parameters:
NameTypeAttributesDescription
typeSpinner.Type

Spinner value type. Valid values are Spinner.DataType.[Number|List|DateTime]

list_or_formatstring | Array.<*><optional>

Format of how the value should be displayed (for numbers), or Array of list items (when type is Spinner.DataType.List).

minnumber<optional>

The minimum allowed value (numeric or date)

maxnumber<optional>

The maximum allowed value (numeric or date).

stepnumber | Spinner.Step<optional>

Step increment used when increasing/decreasing values. Pass number for Number type of spinner and Spinner.Step for DateTime type.

Examples
// Number Type: new Spinner(type, format, min, max, step_size);
new Spinner(Spinner.Type.Number, "0.00", 0, 100, 5);
// List Type: new Spinner(new Array());
new Spinner(Spinner.Type.List, ["Monday","Tuesday","Wednesday","Thursday","Friday"]);
// DateTime type:
new Spinner(Spinner.Type.DateTime, new Date(2000, 0, 1), new Date(2030, 11, 31), "yyyy-MM-dd", Spinner.Step.DayOfMonth);

Classes

Spinner

Members

(readonly) Step :number

Enumeration of step units for {Spinner.Type.DateTime} spinners. Used to define the unit that is incremented or decremented when changing the value.

Type:
  • number

(readonly) Type :number

Enumeration of spinner value types. Used to define what kind of data the spinner will handle.

Type:
  • number

(readonly) selectedText :string

Gets the currently selected text from the spinner's editable area.

Type:
  • string

Methods

caretPosition(positionopt) → {number|Spinner}

Gets or sets the caret (cursor) position in the spinner's editable area.

Parameters:
NameTypeAttributesDescription
positionnumber<optional>

The caret position to set (0-based index).

Returns:

Returns current caret position when called without parameters, or the Spinner instance when setting.

Type: 
number | Spinner

deleteSelection() → {Spinner}

Deletes the currently selected text in the spinner's editable area.

Returns:

The Spinner instance for method chaining.

Type: 
Spinner

max(valueopt) → {number|null|Spinner}

Gets or sets the maximum allowed numeric value for the spinner. Applicable only if the spinner was initialized with {Spinner.Type.Number}, {Spinner.Type.DateTime} or {Spinner.Type.IPv4}. Returns null if spinner type is {Spinner.Type.List}.

Parameters:
NameTypeAttributesDescription
valuenumber<optional>

The maximum value to set.

Returns:

The current maximum value, null if not applicable, or the Spinner instance when setting.

Type: 
number | null | Spinner

min(valueopt) → {number|null|Spinner}

Gets or sets the minimum allowed numeric value for the spinner. Applicable only if the spinner was initialized with {Spinner.Type.Number}, {Spinner.Type.DateTime} or {Spinner.Type.IPv4}. Returns null if spinner type is {Spinner.Type.List}.

Parameters:
NameTypeAttributesDescription
valuenumber<optional>

The minimum value to set.

Returns:

The current minimum value, null if not applicable, or the Spinner instance when setting.

Type: 
number | null | Spinner

selectAll() → {this}

Selects all text in the spinner's editable area.

Returns:

The Spinner instance for method chaining.

Type: 
this

selection(startopt, endopt) → {Object|Spinner}

Get selection object {start, end}, or set the current selection range within the spinner's text.

Parameters:
NameTypeAttributesDescription
startnumber<optional>

The start position of the selection (0-based index).

endnumber<optional>

The end position of the selection (0-based index).

Returns:

Returns the current selection object when called without parameters, or the Spinner instance when setting.

Type: 
Object | Spinner

step(valueopt) → {number|null|Spinner}

Gets or sets the step increment/decrement for the spinner when changing values via arrows or keyboard. Applicable only if the spinner was initialized with {Spinner.Type.Number}, {Spinner.Type.DateTime}, or {Spinner.Type.IPv4}. Returns null if spinner type is {Spinner.Type.List}.

Parameters:
NameTypeAttributesDescription
valuenumber<optional>

The step size to set.

Returns:

The current step size, null if not applicable, or the Spinner instance when setting.

Type: 
number | null | Spinner