NumberPicker

An element which is used to input numbers. It can operate in two modes - text editor or slider. The mode of operation is set using the "number-picker-type" property

Create from source

func NewNumberPicker(session Session, params Params) NumberPicker

Create new number picker object and returns its interface

Create from resource

NumberPicker {
    id = numberPicker,
    number-picker-max = 100,
    number-picker-step = 1,
    number-picker-value = 50,
}

Interface description

Inherit methods, properties and events from View

Properties

"data-list"

Specify an array of recommended values

Constant: DataList

Types: []string, string, []fmt.Stringer, []Color, []SizeUnit, []AngleUnit, []float, []int, []bool, []any containing elements of string, fmt.Stringer, bool, rune, float32, float64, int, int8int64, uint, uint8uint64

Internal type is []string, other types converted to it during assignment

Conversion rules

string - must contain integer or floating point number, converted to []string

[]string - an array of strings which must contain integer or floating point numbers, stored as is

[]fmt.Stringer - object which implement this interface must contain integer or floating point numbers, converted to a []string

[]Color - an array of color values, converted to []string

[]SizeUnit - an array of size unit, converted to []string

[]AngleUnit - an array of angle unit, converted to []string

[]float - converted to []string

[]int - converted to []string

[]bool - converted to []string

[]any - an array which may contain types listed in Types section above, each value will be converted to a string and wrapped to array

Examples

NumberPicker {
    data-list = [
        "1",
        2,
        3.0,
    ],
}
picker := rui.NewNumberPicker(session, rui.Params{
    rui.DataList: []any{
        "1",
        2,
        3.0,
    },
})

"max"

Same as "number-picker-max"

Constant: Max

"min"

Same as "number-picker-min"

Constant: Min

"number-picker-max"

Set the maximum value. The default value is 1

Constant: NumberPickerMax

Types: float, int, string

Internal type is float, other types converted to it during assignment

Examples

NumberPicker {
    number-picker-max = 100,
}
picker := rui.NewNumberPicker(session, rui.Params{
    rui.NumberPickerMax: 100,
})

"number-picker-min"

Set the minimum value. The default value is 0

Constant: NumberPickerMin

Types: float, int, string

Internal type is float, other types converted to it during assignment

Examples

NumberPicker {
    number-picker-min = -100,
}
picker := rui.NewNumberPicker(session, rui.Params{
    rui.NumberPickerMin: -100,
})

"number-picker-step"

Set the value change step

Constant: NumberPickerStep

Types: float, int, string

Internal type is float, other types converted to it during assignment

Examples

NumberPicker {
    number-picker-step = 2,
}
picker := rui.NewNumberPicker(session, rui.Params{
    rui.NumberPickerStep: 2,
})

"number-picker-type"

Sets the visual representation

Constant: NumberPickerType

Types: int, string

Values

int string Description
0(NumberEditor) "editor" Displayed as an editor
1(NumberSlider) "slider" Displayed as a slider

"number-picker-value"

Current value. The default value is 0

Constant: NumberPickerValue

Types: float, int, string

Internal type is float, other types converted to it during assignment

Examples

NumberPicker {
    number-picker-value = 0,
}
picker := rui.NewNumberPicker(session, rui.Params{
    rui.NumberPickerValue: 2,
})

"step"

Same as "number-picker-step"

Constant: Step

"type"

Same as "number-picker-type"

Constant: Type

"value"

Same as "number-picker-value"

Constant: Value

Events

"number-changed"

Set listener(s) that track the change in the entered value

Constant: NumberChangedEvent

General listener format:

func(picker rui.NumberPicker, newValue, oldValue float64)

where: * picker - Interface of a number picker which generated this event * newValue - New value * oldValue - Old Value

Allowed listener formats:

func(picker rui.NumberPicker, newValue float64)

func(newValue, oldValue float64)

func(newValue float64)

func()

func GetDataList(view View, subviewID ...string) []string

Returns the data list of an editor. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned.

func GetNumberChangedListeners(view View, subviewID ...string) []func(NumberPicker, float64, float64)

Returns the NumberChangedListener list of an NumberPicker subview. If there are no listeners then the empty list is returned If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetNumberPickerMinMax(view View, subviewID ...string) (float64, float64)

Returns the min and max value of NumberPicker subview. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetNumberPickerStep(view View, subviewID ...string) float64

Returns the value changing step of NumberPicker subview. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetNumberPickerType(view View, subviewID ...string) int

Returns the type of NumberPicker subview. Possible values are: NumberEditor (0) - NumberPicker is presented by editor (default type); NumberSlider (1) - NumberPicker is presented by slider. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetNumberPickerValue(view View, subviewID ...string) float64

Returns the value of NumberPicker subview. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func NumberPickerByID(rootView View, id string) NumberPicker

Return a NumberPicker with id equal to the argument of the function or nil if there is no such View or View is not NumberPicker