Create NumberPicker objects using the CreateNumberPicker method of the UIExtras object:
picker = uix.CreateNumberPicker( value, options );
When the NumberPicker reaches the first or last item in the list, it will cycle to the other end. To stop cycling, use the NoCycle option.
Use the SetOnChange method to set the name of a function to be called when the value changes.
You can get the current value at any time using the GetValue method, and the SetValue method to set the current value.
Use the SetRange method to set the minimum and maximum values.
Example
app.LoadPlugin( "UIExtras" );
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
uix = app.CreateUIExtras();
picker = uix.CreateNumberPicker( 5, "NoCycle" );
picker.SetRange( -10, 10 );
picker.SetOnChange( OnChange );
lay.AddChild( picker );
app.AddLayout( lay );
}
function OnChange( value )
{
app.ShowPopup( value );
}
By default, the NumberPicker will display values to one decimal place. Use the SetDecimalPlaces method to change this.
The decimal separator character can be changed if required by using the SetDecimalSeparator method.
Example - Two decimal places
app.LoadPlugin( "UIExtras" );
function OnStart()
{
lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
uix = app.CreateUIExtras();
picker = uix.CreateNumberPicker( 0 );
picker.SetDecimalPlaces( 2 );
picker.SetValue( 5.55 );
picker.SetOnChange( OnChange );
lay.AddChild( picker );
app.AddLayout( lay );
}
function OnChange( value )
{
app.ShowPopup( value );
}
The following methods are available on the NumberPicker object:
GetType()
SetOnChange( callback )
SetValue( value )
GetValue()
SetRange( min, max )
SetDecimalPlaces( count )
SetDecimalSeparator( char )
SetTextColor( color )