Back

CustomDialog

Custom dialog boxes pop up and can be used to display temporary information or collect data from the user. They are useful for displaying configuration or settings controls.

You can add all types of control to a CustomDialog object. Dialogs are resizeable and you can also change the look of them so that they fit in with the theme of your application.

Create a custom dialog object using the CreateDialog method of the app object:

 dlg = app.CreateDialog( title, options );
string - comma separated
    "NoCancel" - Back button will not dismiss dialog
    "AutoCancel" - Touching outside dialog will dismiss import
    "NoTitle" - Removes dialog title
    "NoFocus" - Prevents dialog gaining focus
    "NoDim" - Prevents area outside dialog from dimming.

A custom dialog needs a layout to add the controls to. Use the CreateLayout method of the app object to add a layout.

 layDlg = app.CreateLayout( type, options );

Use the Show method to show the dialog.

 dlg.Show();

And the Dismiss method when you want to close it.

 dlg.Dismiss();

Example


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

    btn = app.CreateButton( "Show Dialog", 0.6, 0.1 );
    btn.SetOnTouch( btn_OnTouch );
    lay.AddChild( btn );

    app.AddLayout( lay );
}

function btn_OnTouch()
{
    dlg = app.CreateDialog( "Custom Dialog" );

    layDlg = app.CreateLayout( "linear", "VCenter,FillXY" );
    layDlg.SetSize( 0.7, 0.3 );
    dlg.AddLayout( layDlg );

    chk = app.CreateCheckBox( "Check Box" );
    chk.SetMargins( 0, 0.02, 0, 0.02 );
    layDlg.AddChild( chk );

    btnDlg = app.CreateButton( "Close Dialog", 0.6, 0.1 );
    btnDlg.SetOnTouch( btnDlg_OnTouch );
    layDlg.AddChild( btnDlg );

    dlg.Show();
}

function btnDlg_OnTouch()
{
    dlg.Dismiss();
}
    Copy     Copy All      Run     

See 'CreateDialog for more informations and a complete function list