This shows you the differences between two versions of the page.
built_in:togglebuttons [2015/03/08 10:02] octazid completed |
built_in:togglebuttons [2015/03/22 21:23] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== ToggleButtons ====== | ||
- | // | ||
- | |||
- | ===== Description ===== | ||
- | Create toggle buttons using the CreateToggle method of the app object: | ||
- | < | ||
- | 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( " | ||
- | } | ||
- | </ | ||
- | |||
- | |||
- | ===== Methods ===== | ||
- | Some controls use the same methods.\\ | ||
- | For examples of the **[[same methods]]** look here. | ||
- | ^Method ^Description ^ | ||
- | |ToggleButton.Destroy() | | | ||
- | |ToggleButton.GetAbsHeight() | | | ||
- | |ToggleButton.GetAbsWidth() | | | ||
- | |ToggleButton.GetChecked() | | | ||
- | |ToggleButton.GetHeight() | | | ||
- | |ToggleButton.GetPosition() | | | ||
- | |ToggleButton.GetText() | | | ||
- | |ToggleButton.GetTextSize( mode ) | | | ||
- | |ToggleButton.GetType() | | | ||
- | |ToggleButton.GetVisibility() | | | ||
- | |ToggleButton.GetWidth() | | | ||
- | |ToggleButton.Release() | | | ||
- | |ToggleButton.SetChecked( checked ) | | | ||
- | |ToggleButton.SetMargins( left, | ||
- | |ToggleButton.SetOnTouch( callback ) | | | ||
- | |ToggleButton.SetPadding( left, top, right, bottom ) | | | ||
- | |ToggleButton.SetPosition( left, top, width, height ) | | | ||
- | |ToggleButton.SetScale( x,y ) | | | ||
- | |ToggleButton.SetSize( width, height ) | | | ||
- | |ToggleButton.SetText( text ) | | | ||
- | |ToggleButton.SetTextColor( colorCode ) | | | ||
- | |ToggleButton.SetTextSize( size,mode ) | | | ||
- | |ToggleButton.SetVisibility( HideShow ) | | |