This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
built_in:spinner [2014/12/19 16:11] octazid [Methods] |
built_in:spinner [2015/04/02 16:29] octazid [Methods] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Spinner control ====== | ====== Spinner control ====== | ||
+ | |||
+ | // | ||
+ | |||
+ | =====Description===== | ||
+ | |||
+ | Create Spinners using the **CreateSpinner** method of the [[built_in: | ||
+ | < | ||
+ | |||
+ | 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' | ||
+ | |||
+ | 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( " | ||
+ | |||
+ | spin = app.CreateSpinner( " | ||
+ | spin.SetOnChange( ShowSelection ); | ||
+ | spin.SelectItem( " | ||
+ | lay.AddChild( spin ); | ||
+ | |||
+ | app.AddLayout( lay ); | ||
+ | } | ||
+ | |||
+ | function ShowSelection( item ) | ||
+ | { | ||
+ | app.ShowPopup( " | ||
+ | } | ||
+ | </ | ||
===== Methods ===== | ===== Methods ===== | ||
- | ^Method ^Description ^ | + | Some controls use the same methods.\\ |
- | |Spinner.Destroy() | | | + | For examples of the **[[same methods]]** look here. |
- | |Spinner.GetAbsHeight() | | | + | ^ Method |
- | |Spinner.GetAbsWidth() | | | + | | Spinner.GetAbsHeight() |
- | |Spinner.GetHeight() | | | + | | Spinner.GetAbsWidth() |
- | |Spinner.GetPosition() | | | + | | Spinner.GetHeight() |
- | |Spinner.GetText() | | | + | | Spinner.GetPosition() |
- | |Spinner.GetTextSize( mode ) | | | + | | Spinner.GetText() |
- | |Spinner.GetType() | | | + | | Spinner.GetTextSize( mode ) | |
- | |Spinner.GetVisibility() | | | + | | Spinner.GetType() |
- | |Spinner.GetWidth() | | | + | | Spinner.GetVisibility() |
- | |Spinner.Release() | | | + | | Spinner.GetWidth() |
- | |Spinner.SelectItem( | + | | Spinner.SelectItem( |
- | |Spinner.SetBackColor( | + | | Spinner.SetBackColor( |
- | |Spinner.SetBackGradient( p1, | + | | Spinner.SetBackGradient( p1, |
- | |Spinner.SetBackGradientRadial( p1, | + | | Spinner.SetBackGradientRadial( p1, |
- | |Spinner.SetBackground( p1,p2 ) | | | + | | Spinner.SetList( |
- | |Spinner.SetList( | + | | Spinner.SetMargins( left, |
- | |Spinner.SetMargins( left, | + | | Spinner.SetOnChange( |
- | |Spinner.SetOnChange( | + | | Spinner.SetOnTouch( |
- | |Spinner.SetOnTouch( | + | | Spinner.SetPadding( |
- | |Spinner.SetPadding( | + | | Spinner.SetPosition( |
- | |Spinner.SetPosition( | + | | Spinner.SetScale( x,y ) | |
- | |Spinner.SetScale( x,y ) | | | + | | Spinner.SetSize( |
- | |Spinner.SetSize( | + | | Spinner.SetText( |
- | |Spinner.SetText( | + | | Spinner.SetTextColor( |
- | |Spinner.SetTextColor( | + | | Spinner.SetTextSize( size,mode ) |
- | |Spinner.SetTextSize( size,mode ) | | | + | | Spinner.SetVisibility( |
- | |Spinner.SetVisibility( | + | |
+ | |||
+ | ---- | ||
+ | |||
+ | ===== 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( " | ||
+ | |||
+ | spin = app.CreateSpinner( " | ||
+ | spin.SetOnChange( ShowSelection ); | ||
+ | // | ||
+ | lay.AddChild( spin ); | ||
+ | |||
+ | app.AddLayout( lay ); | ||
+ | //Select the Item after app.AddLayout or | ||
+ | //it will not work right! | ||
+ | spin.SelectItem( " | ||
+ | } | ||
+ | |||
+ | |||
+ | function ShowSelection( item ) | ||
+ | { | ||
+ | app.ShowPopup( " | ||
+ | } | ||
+ | </ |