This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
built_in:togglebuttons [2014/12/05 13:20] 162.252.85.172 [Methods] |
built_in:togglebuttons [2015/03/22 21:23] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== ToggleButtons ====== | ====== ToggleButtons ====== | ||
- | ===== Create | + | |
- | Create toggle buttons using the CreateToggle method of the app object: | + | // |
+ | |||
+ | ===== Description | ||
+ | Create toggle buttons using the **CreateToggle** method of the **[[built_in: | ||
< | < | ||
- | You can allow the toggle button to auto-size by leaving out the dimensions or you can specify a width and height as decimal fractions of the screen' | + | You can allow the toggle button to auto-size by leaving out the dimensions or you can specify a **width** and **height** as decimal fractions of the screen' |
+ | |||
+ | Use the **SetOnTouch** method of your button object to set the name of a function you want to be called when the button is touched. | ||
+ | |||
+ | You can get the state of the toggle button at any time using the **GetChecked** method of the button. The button state is also passed into your OnTouch callback function as a parameter every time the button is touched. | ||
+ | |||
+ | ==== Example ==== | ||
+ | <code javascript> | ||
+ | function OnStart() | ||
+ | { | ||
+ | lay = app.CreateLayout( " | ||
+ | |||
+ | btn = app.CreateToggle( " | ||
+ | btn.SetOnTouch( ShowState ); | ||
+ | lay.AddChild( btn ); | ||
+ | |||
+ | app.AddLayout( lay ); | ||
+ | } | ||
+ | |||
+ | function ShowState( isChecked ) | ||
+ | { | ||
+ | app.ShowPopup( " | ||
+ | } | ||
+ | </ | ||
- | Use the SetOnTouch method of your button object to set the name of a function you want to be called when the button is touched. | ||
- | You can get the state of the toggle button at any time using the GetChecked method of the button. The button state is also passed into your OnTouch callback function as a parameter every time the button is touched. | ||
===== Methods ===== | ===== Methods ===== | ||
- | ^Method ^Description ^ | + | Some controls use the same methods.\\ |
- | |ToggleButton.Destroy() | | | + | For examples of the **[[same methods]]** look here. |
- | |ToggleButton.GetAbsHeight() | | | + | ^ Method |
- | |ToggleButton.GetAbsWidth() | | | + | | ToggleButton.Destroy() |
- | |ToggleButton.GetChecked() | | | + | | ToggleButton.GetAbsHeight() |
- | |ToggleButton.GetHeight() | | | + | | ToggleButton.GetAbsWidth() |
- | |ToggleButton.GetPosition() | | | + | | ToggleButton.GetChecked() |
- | |ToggleButton.GetText() | | | + | | ToggleButton.GetHeight() |
- | |ToggleButton.GetTextSize( mode ) | | | + | | ToggleButton.GetPosition() |
- | |ToggleButton.GetType() | | | + | | ToggleButton.GetText() |
- | |ToggleButton.GetVisibility() | | | + | | ToggleButton.GetTextSize( mode ) | | |
- | |ToggleButton.GetWidth() | | | + | | ToggleButton.GetType() |
- | |ToggleButton.Release() | | | + | | ToggleButton.GetVisibility() |
- | |ToggleButton.SetBackColor( p1 ) | | | + | | ToggleButton.GetWidth() |
- | |ToggleButton.SetBackGradient( p1, | + | | ToggleButton.SetChecked( |
- | |ToggleButton.SetBackGradientRadial( p1, | + | | ToggleButton.SetMargins( left, |
- | |ToggleButton.SetBackground( p1,p2 ) | | | + | | ToggleButton.SetOnTouch( |
- | |ToggleButton.SetChecked( | + | | ToggleButton.SetPadding( |
- | |ToggleButton.SetMargins( left, | + | | ToggleButton.SetPosition( |
- | |ToggleButton.SetOnTouch( | + | | ToggleButton.SetScale( x,y ) | | |
- | |ToggleButton.SetPadding( | + | | ToggleButton.SetSize( |
- | |ToggleButton.SetPosition( | + | | ToggleButton.SetText( |
- | |ToggleButton.SetScale( x,y ) | | | + | | ToggleButton.SetTextColor( |
- | |ToggleButton.SetSize( | + | | ToggleButton.SetTextSize( size,mode ) |
- | |ToggleButton.SetText( | + | | ToggleButton.SetVisibility( |
- | |ToggleButton.SetTextColor( | + | |
- | |ToggleButton.SetTextSize( size,mode ) | | | + | |
- | |ToggleButton.SetVisibility( | + |