User Tools

Site Tools


Sidebar

Privacy Policy

News

Version 2.50 is out since Jan 1st 2022


Frequently Asked Questions


Namespaces

Note for contributors

If you wish to create a new page in the DroidScript wiki, please click on the most appropriate namespace above and follow the notes for contributors there.

Because of spam, it has been necessary to add a CAPTCHA to the registration form and the save option for editing pages. You will not need to prove you are human if you are logged in, so please register.

Please feel free to improve any existing page, as well as adding new pages to increase the sum of public knowledge about DroidScript.

Formatting Syntax

sample_code:custom_dialog

This is an old revision of the document!


Custom Yes-No-Dialog

(Sample posted by Chris Hopkins in the DroidScrip Google Group)

If you want to show a popup window on exit, you could use a custom Dialog.
For example, this is a small app that pops up a custom dialog when the back button is pressed

custom_yes_no_dialog.js
//Called after application is started.
    function OnStart()
    {
        app.EnableBackKey( false );
        app.ShowPopup( "Touch the Back Buttom" );
    }
 
    function OnBack()
    {              
        //Create dialog window.
        dlgExit = app.CreateDialog( "Exit?" );
 
        //Create a layout for dialog.
        layDlg = app.CreateLayout( "Linear", "Horizontal,FillXY" );
        layDlg.SetPadding( 0.02, 0.02, 0.02, 0.02 );
        dlgExit.AddLayout( layDlg );
 
        var btnYes = app.CreateButton("[fa-check-circle] Yes", 0.3, -1, "FontAwesome");
        btnYes.SetTextSize( 24 );
        btnYes.SetOnTouch( btnYes_OnTouch );
        layDlg.AddChild( btnYes );
 
        var btnNo = app.CreateButton("[fa-times-circle] No", 0.3, -1, "FontAwesome");
        btnNo.SetOnTouch( btnNo_OnTouch );
        btnNo.SetTextSize( 24 );
        layDlg.AddChild( btnNo );
 
        //Show dialog.
        dlgExit.Show();
    }
 
    function btnYes_OnTouch()
    {
        dlgExit.Dismiss();
        app.Exit();
    }
 
    function btnNo_OnTouch()
    {
        dlgExit.Dismiss();
    }
sample_code/custom_dialog.1425397257.txt.gz · Last modified: 2015/03/03 23:40 (external edit)