User Tools

Site Tools


sample_code:custom_dialog

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sample_code:custom_dialog [2015/03/03 15:40]
octazid created
sample_code:custom_dialog [2015/08/20 12:55]
Line 1: Line 1:
-=====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\\ 
  
-<code javascript 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(); 
-    } 
-</code> 
sample_code/custom_dialog.txt ยท Last modified: 2015/08/20 12:55 (external edit)