Back

Picker

Create Picker objects using the CreatePicker method of the UIExtras object:

 picker = uix.CreatePicker( list, width, height, options );

The list parameter should be a comma separated list of items. When the Picker 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 selected item changes.

You can get the current selected item at any time using the GetText method. Change the list at any time by using the SetList method.

Use the SelectItem method to set the current selected item.

Example

app.LoadPlugin( "UIExtras" );

function OnStart()
{
 lay = app.CreateLayout( "Linear", "VCenter,FillXY" );

 uix = app.CreateUIExtras();
 
 picker = uix.CreatePicker( "Bilbo,Frodo,Gandalf", 0.4 );
 picker.SetOnChange( OnChange );
 lay.AddChild( picker );
 
 app.AddLayout( lay );
}

function OnChange( item, index )
{
 app.ShowPopup( item + " : " + index );
}
  Copy   Copy All    Run   

The following methods are available on the Picker object:

 GetType()
 SetOnChange( callback )
 SelectItem( item )
 GetText()
 SetList( list, delim )
 SetTextColor( color )
 SetColor( color )