User Tools

Site Tools


built_in:spinner

Differences

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

Link to this comparison view

Next revision
Previous revision
built_in:spinner [2014/12/18 21:54]
bcarroll created
built_in:spinner [2016/06/04 01:02] (current)
Line 1: Line 1:
 ====== Spinner control ====== ====== Spinner control ======
 +
 +//(Description and Example taken from the DroidScript documentation)//
 +
 +=====Description=====
 +
 +Create Spinners using the **CreateSpinner** method of the [[built_in:app|app]] object:
 +<code>spin = app.CreateSpinner( list, width, height, options );</code>
 +
 +You can allow the Spinner to auto-size by leaving out the dimensions or you can specify a width and/or height as decimal fractions of the screen's width and height.
 +
 +Use the **SetOnChange** method of your spinner to set the name of a function you want to be called when the user selects an item.
 +
 +You can get the current selection of the Spinner button at any time using the **GetText** method and replace the option list at any time by using the SetList method.
 +
 +Use the **SelectItem** method to select a particular item in code
 +
 +=====Example=====
 +<code javascript>
 +function OnStart()
 +{
 +  lay = app.CreateLayout( "Linear", "VCenter,FillXY" );
 +
 +  spin = app.CreateSpinner( "Bilbo,Frodo,Gandalf", 0.4 );
 +  spin.SetOnChange( ShowSelection );
 +  spin.SelectItem( "Frodo" );
 +  lay.AddChild( spin );
 +
 +  app.AddLayout( lay );
 +}
 +
 +function ShowSelection( item )
 +{
 +  app.ShowPopup( "Selected = " + item );
 +}
 +</code>
  
 ===== Methods ===== ===== Methods =====
-^Method ^Description ^ +Some controls use the same methods.\\ 
-|Spinner.SetOnTouchp1 ) | | +For examples of the **[[same methods]]** look here. 
-|Spinner.SetTextp1 ) | | +^ Method                                                 ^ Description                                                                
-|Spinner.GetText() | | +| Spinner.GetAbsHeight()                                                                                                            
-|Spinner.SetTextColor( p1 ) | | +| Spinner.GetAbsWidth()                                                                                                             | 
-|Spinner.SetTextSize( p1 ) | | +| Spinner.GetHeight()                                    |                                                                            | 
-|Spinner.SetList( p1, p2 ) | |+| Spinner.GetPosition()                                  |                                                                            
 +| Spinner.GetText()                                                                                                                 
 +| Spinner.GetTextSize( mode )                            |                                                                            | 
 +| Spinner.GetType()                                      |                                                                            | 
 +| Spinner.GetVisibility()                                |                                                                            | 
 +| Spinner.GetWidth()                                                                                                                | 
 +| Spinner.SelectItem( item )                             | See the info                                                               | 
 +| Spinner.SetBackColor( colorcode )                      |                                                                            | 
 +| Spinner.SetBackGradient( p1,p2,p3,p4,p5,p6,p7                                                                                   
 +| Spinner.SetBackGradientRadial( p1,p2,p3,p4,p5,p6,p7                                                                             
 +| Spinner.SetList( list, p2 )                                                                                                       | 
 +| Spinner.SetMargins( left,top,right,bottom )            |                                                                            | 
 +| Spinner.SetOnChange( callback )                        | Note: callback runs only when selection changes, not necessarily touched. 
 +| Spinner.SetOnTouch( callback )                         | Deprecated: same as SetOnChange                                            | 
 +| Spinner.SetPadding( left,top,right,bottom )            |                                                                            | 
 +| Spinner.SetPosition( left,top,width,height )                                                                                      | 
 +| Spinner.SetScale( x,y )                                |                                                                            | 
 +| Spinner.SetSize( width,height )                        |                                                                            | 
 +| Spinner.SetText( text )                                |                                                                            | 
 +| Spinner.SetTextColor( colorcode )                      |                                                                            | 
 +| Spinner.SetTextSize( size,mode )                                                                                                  | 
 +| Spinner.SetVisibility( HideShow )                      |                                                                            | 
 + 
 + 
 +---- 
 + 
 +===== Info to Version 1.15 and before ===== 
 +If the SelectItem method is called before the spinner and the layout is added to the app-object the OnChange event of the spinner is fired only after the second manual selection change.  
 + 
 +<code JavaScript spinnerSelectItem.js> 
 +function OnStart() 
 +
 +  lay = app.CreateLayout( "Linear", "VCenter,FillXY" ); 
 + 
 +  spin = app.CreateSpinner( "Bilbo,Frodo,Gandalf", 0.4 ); 
 +  spin.SetOnChange( ShowSelection ); 
 +  //spin.SelectItem( "Frodo" ); Dont write it here! 
 +  lay.AddChild( spin ); 
 + 
 +  app.AddLayout( lay ); 
 +  //Select the Item after app.AddLayout or 
 +  //it will not work right! 
 +  spin.SelectItem( "Frodo" ); 
 +
 + 
 + 
 +function ShowSelection( item ) 
 +
 +  app.ShowPopup( "Selected = " + item ); 
 +
 +</code>
built_in/spinner.1418939682.txt.gz · Last modified: 2014/12/19 05:54 (external edit)