Back

DatePicker

Create DatePicker objects using the CreateDatePicker method of the UIExtras object:

 picker = uix.CreateDatePicker( year, month, day, options );

By default the DatePicker will use a spinner view, you can use the Calendar option to use a calendar view instead.

Example - DatePicker Spinner

app.LoadPlugin( "UIExtras" );

function OnStart()
{
 lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
 
 uix = app.CreateUIExtras();
 
 picker = uix.CreateDatePicker();
 picker.SetOnDateChanged( OnDateChanged );
 lay.AddChild( picker );
 
 app.AddLayout( lay );
}

function OnDateChanged( year, month, day )
{
 var date = new Date();
 date.setFullYear( year, month, day);
 
 app.ShowPopup( date.toDateString() );
}
  Copy   Copy All    Run   

Example - DatePicker Calendar

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

 uix = app.CreateUIExtras();
 
 picker = uix.CreateDatePicker( 2016, 0, 1, "Calendar" );
 picker.SetOnDateChanged( OnDateChanged );
 lay.AddChild( picker );
 
 app.AddLayout( lay );
}

function OnDateChanged( year, month, day )
{
 var date = new Date();
 date.setFullYear( year, month, day);

 app.ShowPopup( date.toDateString() );
}
  Copy   Copy All    Run   

The following methods are available on the DatePicker object:

 GetType()
 SetDate( year, month, day )
 SetMinDate( year, month, day )
 SetMaxDate( year, month, day )
 SetOnDateChanged( callback )