Remarks
This class provides the most basic of buttons. It has no explicit UI and requires the user to implement any look for the control. A button class will process mouse clicks however and will fire Click events.
Examples
This example displays creating a simple custom button. The button uses the background color to represent the up and down state, the down state a darkened version of the background color.
Creating a Custom Button | ![]() |
---|---|
import "Turbine.UI"; import "Turbine.Utils"; TestButton = class( Turbine.UI.Button ); function TestButton:Constructor() Turbine.UI.Button.Constructor( self ); self:SetBackColor( Turbine.UI.Color( 1, 0.4, 0.4, 1 ) ); self:SetSize( 40, 40 ); self.MouseDown = function( sender, args ) Turbine.UI.Button.SetBackColor( sender, self.halfBackColor ); end self.MouseUp = function( sender, args ) Turbine.UI.Button.SetBackColor( sender, self.backColor ); end end function TestButton:SetBackColor( color ) Turbine.UI.Button.SetBackColor( self, color ); self.backColor = color self.halfBackColor = Turbine.UI.Color( color.A, color.R / 2, color.G / 2, color.B / 2 ); end -- Test the custom button. window = Turbine.UI.Lotro.Window(); window:SetPosition( 100, 100 ); window:SetSize( 200, 100 ); window:SetText( "Test Window" ); window:SetVisible( true ); customButton = TestButton(); customButton:SetPosition( 40, 40 ); customButton:SetSize( 120, 40 ); customButton:SetParent( window ); customButton:SetBackColor( Turbine.UI.Color( 0.2, 0.2, 1 ) ); customButton.Click = function( sender, args ) Turbine.Shell.WriteLine( "Thanks for clicking me!" ); end |
Inheritance Hierarchy
Turbine.Object
Turbine.UI.Control
Turbine.UI.ScrollableControl
Turbine.UI.Label
Turbine.UI.Button
Turbine.UI.Lotro.Button
Turbine.UI.Control
Turbine.UI.ScrollableControl
Turbine.UI.Label
Turbine.UI.Button
Turbine.UI.Lotro.Button