Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Called when application is started.
- function OnStart()
- {
- //Force app to Portrait mode.
- app.SetOrientation( "Portrait" );
- //Create a layout with objects vertically centered.
- lay = app.CreateLayout( "linear", "VCenter,FillXY" );
- //Create some text.
- txt = app.CreateText( "Text" );
- txt.SetTextSize( 22 );
- lay.AddChild( txt );
- //Create an image with width of 0.1 x screen width.
- img = app.CreateImage( "/Sys/Img/Droid1.png", 0.1 );
- img.SetMargins( 0, 0.02, 0, 0 );
- img.SetOnTouchDown( img_OnTouchDown );
- lay.AddChild( img );
- //Create a button.
- btn = app.CreateButton( "Button", 0.4 );
- btn.SetMargins( 0, 0.02, 0, 0 );
- btn.SetOnTouch( btn_OnTouch );
- lay.AddChild( btn );
- //Create a toggle button.
- tgl = app.CreateToggle( "Toggle Button", 0.4 );
- tgl.SetMargins( 0, 0.02, 0, 0 );
- tgl.SetOnTouch( tgl_OnTouch );
- lay.AddChild( tgl );
- //Create a check box.
- chk = app.CreateCheckBox( "Check Box" );
- chk.SetMargins( 0, 0.02, 0, 0 );
- chk.SetOnTouch( chk_OnTouch );
- lay.AddChild( chk );
- //Create spinner.
- spin = app.CreateSpinner( "Spinner,A,B,C", 0.3 );
- spin.SetOnTouch( spin_OnChange );
- lay.AddChild( spin );
- //Create an text edit box.
- edt = app.CreateTextEdit( "Text Edit", 0.6, 0.1 );
- edt.SetMargins( 0, 0.02, 0, 0 );
- lay.AddChild( edt );
- //Create a list box.
- lst = app.CreateList( "Fred,Bill,Jim", 0.6, 0.2 );
- lst.SetMargins( 0, 0.03, 0, 0 );
- lst.SetOnTouch( lst_OnTouch );
- lst.SetOnLongTouch( lst_OnLongTouch );
- lay.AddChild( lst );
- //Create a seek bar.
- skb = app.CreateSeekBar( 0.8 );
- skb.SetOnTouch( skb_OnTouch );
- skb.SetRange( 1.0 );
- skb.SetValue( 0.5 );
- lay.AddChild( skb );
- //Add layout to app.
- app.AddLayout( lay );
- }
- //Handle we user touches the image.
- function img_OnTouchDown( ev )
- {
- //Display the x y posn within image.
- var x = ev.x[0];
- var y = ev.y[0];
- app.ShowPopup( "Image: " + x + ", " + y );
- }
- //Called when user touches our button.
- function btn_OnTouch()
- {
- app.ShowPopup( "Button" );
- }
- //Called when user touches check box.
- function chk_OnTouch( isChecked )
- {
- app.ShowPopup( "Checked = " + isChecked );
- }
- //Called when user touches our toggle button.
- function tgl_OnTouch( isChecked )
- {
- app.ShowPopup( "Checked = " + isChecked );
- }
- //Called when user changes the selection.
- function spin_OnChange( item )
- {
- app.ShowPopup( "Item = " + item );
- }
- //Called when user touches a list item.
- function lst_OnTouch( item )
- {
- app.ShowPopup( "Item = " + item );
- }
- //Called when user long-touches a list item.
- function lst_OnLongTouch( item )
- {
- app.ShowPopup( "Long Touch = " + item );
- }
- //Called when seek bar is touched.
- function skb_OnTouch( value )
- {
- app.ShowPopup( "Value = " + value );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement