NumberPicker

The NumberPicker element extends the View interface to enter numbers.

To create a NumberPicker, the function is used:

func NewNumberPicker(session Session, params Params) NumberPicker

NumberPicker can work in two modes: text editor and slider.The mode sets the int property "number-picker-type" (NumberPickerType constant).The "number-picker-type" property can take the following values:

Value Constant Name Editor type
0 NumberEditor "editor" Text editor. Default value
1 NumberSlider "slider" Slider

You can set/get the current value using the "number-picker-value" property (NumberPickerValue constant).The following can be passed as a value to the "number-picker-value" property:

  • float64
  • float32
  • int
  • int8 … int64
  • uint
  • uint8 … uint64
  • textual representation of any of the above types

All of these types are cast to float64. Accordingly, the Get function always returns a float64 value.The value of the "number-picker-value" property can also be read using the function:

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

The entered values may be subject to restrictions. For this, the following properties are used:

Property Constant Restriction
"number-picker-min" NumberPickerMin Minimum value
"number-picker-max" NumberPickerMax Maximum value
"number-picker-step" NumberPickerStep Value change step

Assignments to these properties can be the same value types as "number-picker-value".

By default, if "number-picker-type" is equal to NumberSlider, the minimum value is 0, maximum is 1.If "number-picker-type" is equal to NumberEditor, then the entered numbers, by default, are limited only by the range of float64 values.

You can read the values of these properties using the functions:

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

The "number-changed" event (NumberChangedEvent constant) is used to track the change in the entered value.The main event listener has the following format:

func(picker NumberPicker, newValue, oldValue float64)

where the second argument is the new value, the third argument is the previous value.

Additional event listeners can have the following format

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

You can get the current list of value change listeners using the function

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