Advertisement
liar_red

Untitled

Mar 1st, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. //Called when application is started.
  3. function OnStart()
  4. {
  5.     //Force app to Portrait mode.
  6.     app.SetOrientation( "Portrait" );
  7.      
  8.     //Create a layout with objects vertically centered.
  9.     lay = app.CreateLayout( "linear", "VCenter,FillXY" );    
  10.  
  11.     //Create some text.
  12.     txt = app.CreateText( "Text" );
  13.     txt.SetTextSize( 22 );
  14.     lay.AddChild( txt );
  15.    
  16.     //Create an image with width of 0.1 x screen width.
  17.     img = app.CreateImage( "/Sys/Img/Droid1.png", 0.1 );
  18.     img.SetMargins( 0, 0.02, 0, 0 );
  19.     img.SetOnTouchDown( img_OnTouchDown );
  20.     lay.AddChild( img );
  21.  
  22.     //Create a button.
  23.     btn = app.CreateButton( "Button", 0.4 );
  24.     btn.SetMargins( 0, 0.02, 0, 0 );
  25.     btn.SetOnTouch( btn_OnTouch );
  26.     lay.AddChild( btn );
  27.    
  28.     //Create a toggle button.
  29.     tgl = app.CreateToggle( "Toggle Button", 0.4 );
  30.     tgl.SetMargins( 0, 0.02, 0, 0 );
  31.     tgl.SetOnTouch( tgl_OnTouch );
  32.     lay.AddChild( tgl );
  33.  
  34.     //Create a check box.
  35.     chk = app.CreateCheckBox( "Check Box" );
  36.     chk.SetMargins( 0, 0.02, 0, 0 );
  37.     chk.SetOnTouch( chk_OnTouch );
  38.     lay.AddChild( chk );
  39.  
  40.     //Create spinner.
  41.     spin = app.CreateSpinner( "Spinner,A,B,C", 0.3 );
  42.     spin.SetOnTouch( spin_OnChange );
  43.     lay.AddChild( spin );
  44.    
  45.     //Create an text edit box.
  46.     edt = app.CreateTextEdit( "Text Edit", 0.6, 0.1 );
  47.     edt.SetMargins( 0, 0.02, 0, 0 );
  48.     lay.AddChild( edt );
  49.    
  50.     //Create a list box.
  51.     lst = app.CreateList( "Fred,Bill,Jim", 0.6, 0.2 );
  52.     lst.SetMargins( 0, 0.03, 0, 0 );
  53.     lst.SetOnTouch( lst_OnTouch );
  54.     lst.SetOnLongTouch( lst_OnLongTouch );
  55.     lay.AddChild( lst );
  56.    
  57.     //Create a seek bar.
  58.     skb = app.CreateSeekBar( 0.8 );
  59.     skb.SetOnTouch( skb_OnTouch );
  60.     skb.SetRange( 1.0 );
  61.     skb.SetValue( 0.5 );
  62.     lay.AddChild( skb );
  63.    
  64.     //Add layout to app.    
  65.     app.AddLayout( lay );
  66. }
  67.  
  68. //Handle we user touches the image.
  69. function img_OnTouchDown( ev )
  70. {
  71.     //Display the x y posn within image.
  72.     var x = ev.x[0];  
  73.     var y = ev.y[0];
  74.     app.ShowPopup( "Image: " + x + ", " + y );
  75. }
  76.  
  77. //Called when user touches our button.
  78. function btn_OnTouch()
  79. {
  80.     app.ShowPopup( "Button" );
  81. }
  82.  
  83. //Called when user touches check box.
  84. function chk_OnTouch( isChecked )
  85. {
  86.     app.ShowPopup( "Checked = " + isChecked );
  87. }
  88.  
  89. //Called when user touches our toggle button.
  90. function tgl_OnTouch( isChecked )  
  91. {
  92.     app.ShowPopup( "Checked = " + isChecked );
  93. }
  94.  
  95. //Called when user changes the selection.
  96. function spin_OnChange( item )
  97. {
  98.     app.ShowPopup( "Item = " + item );
  99. }
  100.  
  101. //Called when user touches a list item.
  102. function lst_OnTouch( item )  
  103. {
  104.     app.ShowPopup( "Item = " + item );
  105. }
  106.  
  107. //Called when user long-touches a list item.
  108. function lst_OnLongTouch( item )  
  109. {
  110.     app.ShowPopup( "Long Touch = " + item );
  111. }
  112.  
  113. //Called when seek bar is touched.
  114. function skb_OnTouch( value )
  115. {
  116.     app.ShowPopup( "Value = " + value );
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement