User Tools

Site Tools


built_in:buttons

Differences

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

Link to this comparison view

built_in:buttons [2015/03/08 10:39]
octazid [Description]
built_in:buttons [2018/07/21 05:36]
Line 1: Line 1:
-=====The Button control===== 
- 
-//(Information and examples taken from the DroidScript documentation)// 
- 
-=====Description===== 
- 
-Create buttons using the **CreateButton** method of the **[[built_in:app|app]]** object:  
- 
-<code>btn = app.CreateButton( text, width, height, options );</code> 
- 
-You can allow the button to auto-size by leaving out the dimensions or you can specify a **width** and **height** as decimal fractions. Setting the width and height to -1 whilst using the **'FillX'** option will allow it to fill the layout width. 
- 
-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. 
- 
-Various button **styles** can be set by including a style name in the options parameter 
- 
----- 
- 
-===== Methods ===== 
-Some controls use the same methods.\\ 
-For examples of the **[[same methods]]** look here. 
-^Method ^Description ^ 
-|Button.Destroy() | | 
-|Button.GetAbsHeight() | | 
-|Button.GetAbsWidth() | | 
-|Button.GetHeight() | | 
-|Button.GetPosition() | | 
-|Button.GetText() | | 
-|Button.GetTextSize( mode ) | | 
-|Button.GetType() | | 
-|Button.GetVisibility() | | 
-|Button.GetWidth() | | 
-|Button.Release() | | 
-|Button.SetBackColor( color ) | | 
-|Button.SetBackGradient( color1,color2,color3,p4,p5,p6,p7 ) | | 
-|Button.SetBackGradientRadial( x,y,r,color1,color2,color3,p7 ) | | 
-|Button.SetBackground( imagefile,options ) | | 
-|Button.SetFontFile( file ) | | 
-|Button.SetHtml( html ) | | 
-|Button.SetMargins( left,top,right,bottom ) | | 
-|Button.SetOnTouch( callback ) | | 
-|Button.SetOnTouchEx( p1 ) | | 
-|Button.SetPadding( left,top,right,bottom ) | | 
-|Button.SetPosition( left, top, width, height ) | | 
-|Button.SetScale( x,y ) | | 
-|Button.SetSize( width, height ) | | 
-|Button.SetText( text ) | | 
-|Button.SetTextColor( colorcode ) | | 
-|Button.SetTextShadow( radius,dx,dy,color ) | | 
-|Button.SetTextSize( size,mode ) | | 
-|Button.SetVisibility( HideShow ) | | 
- 
-===== Options ===== 
- 
-^Option ^Description ^ 
-|Alum| Display the Button in aluminuim style| 
-|FillX| Fill the layout width| 
-|Gray| Display the Button in Gray Color| 
- 
----- 
- 
-====Example - Default Size==== 
- 
-<code javascript> 
- 
-function OnStart() 
-{ 
-  lay = app.CreateLayout( "Linear", "VCenter,FillXY" ); 
- 
-  btn = app.CreateButton( "Press Me" ); 
-  btn.SetOnTouch( SayHello ); 
-  lay.AddChild( btn ); 
- 
-  app.AddLayout( lay ); 
-} 
- 
-function SayHello() 
-{ 
-  app.ShowPopup("Hello World!"); 
-} 
- 
-</code> 
- 
-====Example - Fixed Size==== 
- 
-<code javascript> 
- 
-function OnStart() 
-{ 
-  lay = app.CreateLayout( "Linear", "VCenter,FillXY" ); 
- 
-  btn = app.CreateButton( "Press Me", 0.5, 0.2 ); 
-  btn.SetOnTouch( SayHello ); 
-  lay.AddChild( btn ); 
- 
-  app.AddLayout( lay ); 
-} 
- 
-function SayHello() 
-{ 
-  app.ShowPopup("Hello World!"); 
-} 
- 
-</code> 
- 
-====Example - Fill layout width==== 
- 
-<code javascript> 
- 
-function OnStart() 
-{ 
-  lay = app.CreateLayout( "Linear", "VCenter,FillXY" ); 
-  lay.SetPadding( 0.02, 0.02, 0.02, 0.02 ); 
- 
-  btn = app.CreateButton( "Press Me", -1, -1, "FillX" ); 
-  btn.SetOnTouch( SayHello ); 
-  lay.AddChild( btn ); 
- 
-  app.AddLayout( lay ); 
-} 
- 
-function SayHello() 
-{ 
-  app.ShowPopup("Hello World!"); 
-} 
- 
-</code> 
- 
-====Example - Change Style==== 
- 
-<code javascript> 
- 
-function OnStart() 
-{ 
-  lay = app.CreateLayout( "Linear", "Vertical,FillXY" ); 
-  lay.SetPadding( 0.1, 0.1, 0.1, 0 ); 
- 
-  b1 = app.CreateButton( "Normal", -1, -1, "FillX" ); 
-  lay.AddChild( b1 ); 
- 
-  b2 = app.CreateButton( "Gray", -1, -1, "FillX,Gray" ); 
-  lay.AddChild( b2 ); 
- 
-  b3 = app.CreateButton( "Alum", -1, -1, "FillX,Alum" ); 
-  lay.AddChild( b3 ); 
- 
-  app.AddLayout( lay ); 
-} 
- 
-</code> 
  
built_in/buttons.txt ยท Last modified: 2018/07/21 05:36 (external edit)