User Tools

Site Tools


sample_code:about_dialog

Differences

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

Link to this comparison view

sample_code:about_dialog [2015/01/25 14:17]
octazid Created
sample_code:about_dialog [2015/01/25 22:32]
Line 1: Line 1:
-======About Dialog====== 
  
-First create a .js-File and save it as **aboutdlg.js** in a Droidscriptfolder where you need the file.\\  
-Then write the informations you want to display in the dialogbox on a seperate HTML-file.\\ Call it **about.html** and put the file in the same folder. So it is later easy to change the informations. 
- 
-<code Javascript aboutdlg.js> 
-/******************************************************************** 
- * About Dialog 
-===================================================================== 
- * Creation date: 22-01-2015 by octazid 
- * Last update: 22-01-2015 by octazid 
-===================================================================== 
- * Simple dialog to show some things about the app 
-********************************************************************/ 
- 
-//*** AboutDialog class ***// 
-function AboutDialog(information, infowidth, infoheight, backcolor) 
-{ 
-  var self = this; 
-  this.dlg = app.CreateDialog("About:"); 
-  this.lay = app.CreateLayout( "linear", "FillXY" ); 
-  this.txt = app.CreateWebView(infowidth, infoheight); 
-  this.txt.SetBackColor(backcolor); 
-  this.txt.LoadHtml(information); 
-  this.txt.SetMargins(0,0.01,0,0); 
-  this.txt.parent = self; 
-  this.lay.AddChild(this.txt); 
-  this.btnlay = app.CreateLayout( "Linear", "Horizontal,FillXY" ); 
-  this.dlgbtn = app.CreateButton("OK", 0.45,-1); 
-  this.dlgbtn.parent = self; 
-  this.dlgbtn.SetOnTouch(dlgbtn_OnTouch); 
-  this.btnlay.AddChild(this.dlgbtn); 
-  this.lay.AddChild(this.btnlay); 
-  this.dlg.AddLayout(this.lay); 
-  this.Show = function(){self.dlg.Show();} 
-  this.Hide = function(){self.dlg.Hide();} 
-}//function AboutDialog() 
- 
- 
-// Called if button is touched 
-function dlgbtn_OnTouch() 
-{ 
-    var par = this.parent; 
-    par.Hide(); 
-}//function dlgbtn_OnTouch 
-</code> 
- 
-In your app you have to do three things,\\ \\  
-1. Load the Script with 
-    app.LoadScript("aboutdlg.js") 
-2. Create a Button to call the Dialog and add it to the layout 
-    btn = app.CreateButton( "About", 0.3, 0.1, "Alum" ); 
-    btn.SetOnTouch(CreateAboutDlg); 
-    lay.AddChild( btn ); 
-3. Write a function to call the Dialog 
-    function CreateAboutDlg() 
-    { 
-    var txt = app.ReadFile("about.html"); 
-    DlgAbout = new AboutDialog(txt, -1, -1, "#ff222222"); 
-    DlgAbout.Show();     
-    } 
-Or you can use this Example. 
-<code Javascript exampleapp.js> 
-//Called when application is started. 
- 
-function OnStart() 
-{ 
-    app.LoadScript("aboutdlg.js"      
-    lay = app.CreateLayout( "Linear", "VCenter,FillXY" );     
-    btn = app.CreateButton( "About", 0.3, 0.1, "Alum" ); 
-    btn.SetOnTouch(CreateAboutDlg); 
-    lay.AddChild( btn ); 
-    app.AddLayout( lay );     
- 
- 
- 
-function CreateAboutDlg() 
-{ 
-    var txt = app.ReadFile("about.html"); 
-    DlgAbout = new AboutDialog(txt, -1, -1, "#ff222222"); 
-    DlgAbout.Show();     
-} 
-</code> 
sample_code/about_dialog.txt ยท Last modified: 2015/01/25 22:32 (external edit)