Back

CreateWizard

Hello World

The wizard is supposed to simplify a configuration progress which requires several inputs and decisions by the user.
These can be settings and usage terms on first startup or an installation process as you might know from desktop applications.

wiz = app.CreateWizard( title, width, height, callback, options )

The callback function will be called each time the user changes the wizard page.
The functions gets the current wizard layout and the page index (starting from 1) to identify the current progress.

Page Initialisation

On the very first call the page index is 0 which means 'initialisation'.
Then you have to create and add all wizard pages to the passed (frame) layout.

In case the user cancels the wizard the index is
-1
.

Note: This function is a premium feature. Please consider subscribing to Premium to use this feature and support DroidScript in its further development.

Example - Demo

function OnStart()
{
    var theme = app.CreateTheme( "light" );
    app.SetTheme( theme );

    wiz = app.CreateWizard( "My Wizard", 0.7, 0.7, OnWizard );
    wiz.Show();
}

function OnWizard( lay, page )
{
    switch( page ) {
    case 0:
        wizTxt = app.CreateText( "", -1, -1, "MultiLine" );
        wizTxt.SetTextSize( 19 );
        lay.AddChild( wizTxt );

        wizFlag = app.CreateText( "[fa-flag-checkered]", -1, -1, "FontAwesome" );
        wizFlag.SetMargins( 0, 0.05, 0, 0 );
        wizFlag.SetTextSize( 64 );
        wizFlag.Gone();
        lay.AddChild( wizFlag );
    break;

    case 1:
        var msg = "This is the first page of your wizard";
        wizTxt.SetText( msg );
    break;

    case 2:
        var msg = "You can put any controls you like here, including"
            + " a webview and have as many pages as you like";
        wizTxt.SetText( msg );
        wizFlag.Gone();
    break;

    case 3:
     wizTxt.SetText( "Wizard complete!" );
     wizFlag.Show();
     wiz.Finish();
    break;

    case 4:
     wiz.Dismiss();
     app.ShowPopup( "Wizard finished" );
    break;

    case -1:
        app.ShowPopup( "Wizard cancelled" );
    }
}
Copy All       Run      

Methods

The following methods are available on the Wizard object:

Finish()
GetButtons() → list: of objects: [ btnCancel, btnPrev, btnNext ]
GetDialog() → app object: Dialog
GetLayout() → app object: Layout
Hide()
IsVisible() → boolean
Show()
string
number: fraction (0..1)
string: comma “,” separated: “AutoCancel” or “NoCancel”, “NoTitle”, “NoFocus”, “NoDim”, “NoKeys”, “TouchModal”, “NoTouch”
app object: Button
function( lay, page )
wiz.Dismiss
Hide the control and remove it from the screen.
wiz.Finish
Indicate that the Wizard is going to finish on the next page.
wiz.GetButtons
Returns the list of the three control buttons at the bottom of the wizard.
wiz.GetDialog
Returns the dialog object of the wizard.
wiz.GetLayout
Return s the content layout object of the wizard.
wiz.GetType
Returns the control class name.
wiz.Hide
Hide the control but keep the layout space free.
wiz.IsVisible
Returns whether the control is currently visible to the user, ignoring overlaying controls.
wiz.Show
Set the visibility of the control to “Show”.