User Tools

Site Tools


built_in:togglebuttons

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
built_in:togglebuttons [2014/09/17 18:42]
stevegarman
built_in:togglebuttons [2015/03/08 10:39]
octazid [Description]
Line 1: Line 1:
 ====== ToggleButtons ====== ====== ToggleButtons ======
-===== Create ===== + 
-Create toggle buttons using the CreateToggle method of the app object:+//(Information and examples taken from the DroidScript documentation)// 
 + 
 +===== Description ===== 
 +Create toggle buttons using the **CreateToggle** method of the **[[built_in:app|app]]** object:
 <code>btn = app.CreateToggle( text, width, height, options );</code> <code>btn = app.CreateToggle( text, width, height, options );</code>
-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's width and height.+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's width and height. 
 + 
 +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( "Linear", "VCenter,FillXY" ); 
 + 
 +  btn = app.CreateToggle( "Toggle Me" ); 
 +  btn.SetOnTouch( ShowState ); 
 +  lay.AddChild( btn ); 
 + 
 +  app.AddLayout( lay ); 
 +
 + 
 +function ShowState( isChecked ) 
 +
 +  app.ShowPopup( "Checked = " + isChecked, "Short" ); 
 +
 +</code>
  
-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 =====
 +Some controls use the same methods.\\
 +For examples of the **[[same methods]]** look here.
 ^Method ^Description ^ ^Method ^Description ^
-|btn.GetChecked| | +|ToggleButton.Destroy() | | 
-|btn.GetHeight| | +|ToggleButton.GetAbsHeight() | | 
-|btn.GetText| | +|ToggleButton.GetAbsWidth() | | 
-|btn.GetVisibility| | +|ToggleButton.GetChecked() | | 
-|btn.GetWidth| | +|ToggleButton.GetHeight() | | 
-|btn.Release| | +|ToggleButton.GetPosition() | | 
-|btn.SetBackColor| | +|ToggleButton.GetText() | | 
-|btn.SetBackGradient| | +|ToggleButton.GetTextSize( mode ) | | 
-|btn.SetBackGradientRadial| | +|ToggleButton.GetType() | | 
-|btn.SetBackground| | +|ToggleButton.GetVisibility() | | 
-|btn.SetChecked| | +|ToggleButton.GetWidth() | | 
-|btn.SetMargins| | +|ToggleButton.Release() | | 
-|btn.SetOnTouch| | +|ToggleButton.SetChecked( checked ) | | 
-|btn.SetPadding| | +|ToggleButton.SetMargins( left,top,right,bottom ) | | 
-|btn.SetPosition| | +|ToggleButton.SetOnTouch( callback ) | | 
-|btn.SetSize| | +|ToggleButton.SetPadding( left, top, right, bottom ) | | 
-|btn.SetText| | +|ToggleButton.SetPosition( left, top, width, height ) | | 
-|btn.SetTextColor| | +|ToggleButton.SetScale( x,y ) | | 
-|btn.SetTextSize| | +|ToggleButton.SetSize( width, height ) | | 
-|btn.SetVisibility| |+|ToggleButton.SetText( text ) | | 
 +|ToggleButton.SetTextColor( colorCode ) | | 
 +|ToggleButton.SetTextSize( size,mode ) | | 
 +|ToggleButton.SetVisibility( HideShow ) | |
built_in/togglebuttons.txt · Last modified: 2015/03/22 21:23 (external edit)