Button

From LoTROInterface Wiki

Jump to: navigation, search


A simple button control.


Methods

Name Description
AppendText Appends text to the end of the label. (Inherited from Label)
DeselectAll Deselects all the text in the control. (Inherited from Label)
GetAllowDrop Gets if the control supports drop operations from drag and drop. (Inherited from Control)
GetBackColor Gets the solid background color of the control. (Inherited from Control)
GetBackColorBlendMode Gets the blend mode applied to the background color. (Inherited from Control)
GetBlendMode Gets the blend mode applied to the background image. (Inherited from Control)
GetControls Gets the list of child controls. (Inherited from Control)
GetFont Gets the current font. (Inherited from Label)
GetFontStyle Gets the font style. (Inherited from Label)
GetForeColor Gets the foreground color. (Inherited from Label)
GetHeight Gets the height of the control. (Inherited from Control)
GetHorizontalScrollBar Gets the horizontal scroll bar. (Inherited from ScrollableControl)
GetLeft Gets the left coordinate of the control. (Inherited from Control)
GetMousePosition Gets the mouse position relative to this control. (Inherited from Control)
GetMouseVisible Gets a flag indicating if the mouse will see this control. (Inherited from Control)
GetOpacity Gets the opacity of the window. (Inherited from Control)
GetOutlineColor Gets the text outline color. (Inherited from Label)
GetParent Gets the parent of the control. (Inherited from Control)
GetPosition Gets the position of the control. (Inherited from Control)
GetSelectedText Gets the selected text of the label. (Inherited from Label)
GetSelectionLength Gets the length of the selected text. (Inherited from Label)
GetSelectionStart Gets the position of the selection start. (Inherited from Label)
GetSize Gets the size of the control. (Inherited from Control)
GetText Gets the text of the label. (Inherited from Label)
GetTextAlignment Gets the alignment of the text within the label. (Inherited from Label)
GetTextLength Gets the length of the text of the label. (Inherited from Label)
GetTop Gets the top coordinate of the window. (Inherited from Control)
GetVerticalScrollBar Gets the vertical scroll bar. (Inherited from ScrollableControl)
GetWantsKeyEvents Gets a flag indicating if the control wants to receive key events. (Inherited from Control)
GetWantsUpdates Gets the flag indicating if the control wants to receive Update notifications. (Inherited from Control)
GetWidth Gets the width of the control. (Inherited from Control)
GetZOrder Gets the Z ordering index of the control. (Inherited from Control)
InsertText Inserts text into the label at the current cursor position. (Inherited from Label)
IsAltKeyDown Test if the alt key is pressed. (Inherited from Control)
IsControlKeyDown Test if the control key is pressed. (Inherited from Control)
IsEnabled Gets a flag indicating if the control is enabled. (Inherited from Control)
IsMultiline Gets if the label is set to display multiple lines. (Inherited from Label)
IsSelectable Gets a flag indicating if the text in the label is selectable. (Inherited from Label)
IsShiftKeyDown Test if the shift key is pressed. (Inherited from Control)
IsVisible Gets a flag indicating if the control is visible. (Inherited from Control)
PointToClient Converts a coordinate from control space to screen space. (Inherited from Control)
PointToScreen Converts a coordinate from control space to screen space. (Inherited from Control)
SelectAll Selects all the text in the control. (Inherited from Label)
SetAllowDrop Sets if the control supports drop operations from drag and drop. (Inherited from Control)
SetBackColor Sets the background color of the control. (Inherited from Control)
SetBackColorBlendMode Sets the blend mode applied to the background color. (Inherited from Control)
SetBackground Sets the background image of the control. (Inherited from Control)
SetBlendMode Sets the blend mode applied to the background image. (Inherited from Control)
SetEnabled Sets a flag indicating if the control is enabled. (Inherited from Control)
SetFont Sets the current font. (Inherited from Label)
SetFontStyle Sets the font style. (Inherited from Label)
SetForeColor Sets the foreground color. (Inherited from Label)
SetHeight Sets the height of the control. (Inherited from Control)
SetHorizontalScrollBar Sets the horizontal scroll bar. (Inherited from ScrollableControl)
SetLeft Sets the left coordinate of the window. (Inherited from Control)
SetMouseVisible Gets a flag indicating if the mouse will see this control. (Inherited from Control)
SetMultiline Sets if the label should display on multiple lines. (Inherited from Label)
SetOpacity Sets the opacity of the window. (Inherited from Control)
SetOutlineColor Sets the text outline color. (Inherited from Label)
SetParent Sets the parent of the control. (Inherited from Control)
SetPosition Sets the position of the control. (Inherited from Control)
SetSelectable Sets a flag indicating if the text in the label can be selected. (Inherited from Label)
SetSelectedText Replaces the selected text. (Inherited from Label)
SetSelection Sets the selected text. (Inherited from Label)
SetSelectionLength Sets the length of the selected text. (Inherited from Label)
SetSelectionStart Sets the position of the selection start. (Inherited from Label)
SetSize Sets the size of the control. (Inherited from Control)
SetText Sets the text of the label. (Inherited from Label)
SetTextAlignment Sets the alignment of the text within the label. (Inherited from Label)
SetTop Sets the top coordinate of the window. (Inherited from Control)
SetVerticalScrollBar Sets the vertical scroll bar. (Inherited from ScrollableControl)
SetVisible Sets the visible flag of a control. (Inherited from Control)
SetWantsKeyEvents Sets a flag indicating if the control wants to receive key events. (Inherited from Control)
SetWantsUpdates Sets the flag indicating if the cotnrol wants to receive update notifications. (Inherited from Control)
SetWidth Sets the width of the control. (Inherited from Control)
SetZOrder Sets the Z order of the control. (Inherited from Control)


Events

Name Description
Click Event fired when the user clicks on the button.
DragDrop Event fired when a drag drop operation is completed. (Inherited from Control)
DragEnter Event fired when a drag drop operation enters the control. (Inherited from Control)
DragLeave Event fired when a drag drop operation leaves the control. (Inherited from Control)
EnabledChanged Event fired when the enabled state of the control changes.
EnabledChanged Event fired when the enabled state of the control changes. (Inherited from Control)
FocusGained Event fired when the control gains focus. (Inherited from Control)
FocusLost Event fired when the control loses focus. (Inherited from Control)
KeyDown Event fired when a key is pressed down. (Inherited from Control)
KeyUp Event fired when a key is released. (Inherited from Control)
MouseClick Event fired when a mouse button is clicked. (Inherited from Control)
MouseDoubleClick Event fired when a mouse button is double clicked. (Inherited from Control)
MouseDown Event fired when a mouse button is pressed. (Inherited from Control)
MouseEnter Event fired when the mouse enters the control. (Inherited from Control)
MouseHover Event fired when the mouse is hovering over the control. (Inherited from Control)
MouseLeave Event fired when the mouse leaves the cotnrol. (Inherited from Control)
MouseMove Event fired when the mouse moves. (Inherited from Control)
MouseUp Event fired when a mouse button is released. (Inherited from Control)
MouseWheel Event fired when a mouse wheel moves. (Inherited from Control)
PositionChanged Event fired when the position of the control changes. (Inherited from Control)
SizeChanged Event fired when the size of the control changes. (Inherited from Control)
Update Event fired every frame when WantsUpdates is enabled. (Inherited from Control)
VisibleChanged Event fired when the visible state of the control changes. (Inherited from Control)


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


Inheritence Hierarchy

Turbine.Object

Turbine.UI.Control
Turbine.UI.ScrollableControl
Turbine.UI.Label
Turbine.UI.Button
Turbine.UI.Lotro.Button
Personal tools