User Tools

Site Tools


app_methods:enablebackkey

Differences

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

Link to this comparison view

Next revision
Previous revision
app_methods:enablebackkey [2015/02/22 09:34]
octazid created
app_methods:enablebackkey [2015/03/04 23:56] (current)
Line 1: Line 1:
-=====app.EnableBackKey===== +=====EnableBackKey===== 
-(Sample taken from the Droidscript documentation)+ 
 +//(Information and examples taken from the DroidScript documentation)// 
 + 
 +====Description==== 
 + 
 +The **EnableBackKey** enables or disables the standard behaviour of the back key in your app. If you disable it, then your app will not close when the back key is pressed. 
 + 
 +When the back button is pressed, the **OnBack** callback function is called (if it exists). This allows you to change the behaviour of this button.  
 + 
 +<code> app.EnableBackKey( enable );</code> 
 + 
 +---- 
 + 
 +====Example==== 
 <code javascript> <code javascript>
 +
 function OnStart() function OnStart()
 { {
-  app.EnableBackKey( false );+  app.EnableBackKey( false );
 } }
  
-function OnBack() +function OnBack()
 { {
-  var yesNo = app.CreateYesNoDialog( "Exit App?" ); +  var yesNo = app.CreateYesNoDialog( "Exit App?" ); 
-  yesNo.SetOnTouch( yesNo_OnTouch );+  yesNo.SetOnTouch( yesNo_OnTouch );
 } }
  
 function yesNo_OnTouch( result ) function yesNo_OnTouch( result )
 { {
-  if( result=="Yes" ) app.Exit();+  if( result=="Yes" ) app.Exit();
 } }
 +
 </code> </code>
app_methods/enablebackkey.1424597691.txt.gz · Last modified: 2015/02/22 17:34 (external edit)