The button element automates generic button functionality, such as swapping texture and font colors automatically according to mouse over and state.
Button | The button element automates generic button functionality, such as swapping texture and font colors automatically according to mouse over and state. |
Implementation Details | A button is composed of 5 levels of components. |
XML Definition | This is the button xml definition. |
XML Tag | |
Optional Attributes | These are optional. |
mirrorTexCoords | Allows you to display a horizontal mirror image of the button textures. |
backgroundtexture | Name of the UI Texture to use for the background image layer. |
highlighttexture | Name of the UI Texture to use for the highlight image layer. |
overlaytexture | Name of the UI Texture to use for the overlay image layer. |
overlayhighlighttexture | Name of the UI Texture to use for the overlay highlight image layer. |
font | The name of the Font definition to use. |
textalign | The text alignment. |
linespacing | An override value for the font line spacing. |
autoresize | Should the height of the button be automatically resized according to it’s text? |
autoresizewidth | Should the width be shrunk automatically to fit it’s text? |
textAutoFitMinScale | If the text min scale value is set to something other than 1.0, the Label Button automatically drop the point size of the font on a non-re sizable Button until the text fits within the Button’s text dimensions, up to the min font scale. |
texturescale | The scale of the texture to be used for the button artwork. |
drawchildrenfirst | This flag allow you to specify the draw order for the button. |
warnOnTextCropped | Should this Button log warning messages if the text is cut off? |
drawHighlightOverBackground | When drawing this button, should the highlight state be drawn over-top the background image? |
Elements | |
TextOffset | The offset for the text within the button dimensions. |
OverlayOffset (DOES NOT WORK) | The offset for the overlay and overlayhighlight images. |
TextColors | The text colors for each button state. |
TexCoords | The texture coordinates for each button state. |
TexSlices | Slice of the associated Ui Texture to display. |
OverlayTexCoords | The texture coordinates for each button state. |
AnimatedImages | The names of AnimatedImage windows to be used as top-level overlays for the various button states. |
ResizeImages | The names of resize images to be used for the various button states. |
Constants | |
Constants | |
Button States | |
Functions | |
Functions | |
ButtonSetText() | Sets the text displayed on the button |
ButtonGetText() | Returns the text currently displayed on the button. |
ButtonSetPressedFlag() | Sets if button should display it’s ‘pressed’ state. |
ButtonGetPressedFlag() | Returns if button is currently pressed. |
ButtonSetHighlightFlag() | Sets if button should be highlighted. |
ButtonGetHighlightFlag() | Sets if button should be highlighted. |
ButtonSetDisabledFlag() | Sets if button is disabled. |
ButtonGetDisabledFlag() | Returns if the button is currently set to disabled. |
ButtonSetStayDownFlag() | Sets if button if the button should remained pressed when the user release the left mouse button. |
ButtonGetStayDownFlag() | Returns if a button is currently set to ‘stay down’ when pressed. |
ButtonSetCheckButtonFlag() | Sets if the button should behave like a check button. |
ButtonGetCheckButtonFlag() | Returns if the button is currently behaving like a check button. |
ButtonStartFlash() | Starts a scriped flash animation with the highlighted image. |
ButtonStopFlash() | Stops an active flash animation. |
ButtonSetTexture() | Sets the texture used for a particular button state. |
ButtonSetTextColor() | Sets the text color used for a particular button state. |
ButtonGetTextDimensions() | Returns the the current text dimensions. |
A button is composed of 5 levels of components. A particular button may contain any subset of the available components. In order, top to bottom, these are:
The background layer texture component that is visible at all times. This texture may in one of four states
When the mouse is over the button, the highlight layer will be drawn on top of the background layer. Depending on the current pressed state, one of the following will be shown
This laying method allows you to create pressed highlight images that are either complete button artwork, or ‘glow’ effects that expose the background layer behind it.
The overlay and overlay highlight, if defined, behaves the same as the background and background highlight.
The text is always drawn last (that is, on top of everything else), with it’s color corresponding to the current button state.
This is the button xml definition.
XML Tag | |
Optional Attributes | These are optional. |
mirrorTexCoords | Allows you to display a horizontal mirror image of the button textures. |
backgroundtexture | Name of the UI Texture to use for the background image layer. |
highlighttexture | Name of the UI Texture to use for the highlight image layer. |
overlaytexture | Name of the UI Texture to use for the overlay image layer. |
overlayhighlighttexture | Name of the UI Texture to use for the overlay highlight image layer. |
font | The name of the Font definition to use. |
textalign | The text alignment. |
linespacing | An override value for the font line spacing. |
autoresize | Should the height of the button be automatically resized according to it’s text? |
autoresizewidth | Should the width be shrunk automatically to fit it’s text? |
textAutoFitMinScale | If the text min scale value is set to something other than 1.0, the Label Button automatically drop the point size of the font on a non-re sizable Button until the text fits within the Button’s text dimensions, up to the min font scale. |
texturescale | The scale of the texture to be used for the button artwork. |
drawchildrenfirst | This flag allow you to specify the draw order for the button. |
warnOnTextCropped | Should this Button log warning messages if the text is cut off? |
drawHighlightOverBackground | When drawing this button, should the highlight state be drawn over-top the background image? |
Elements | |
TextOffset | The offset for the text within the button dimensions. |
OverlayOffset (DOES NOT WORK) | The offset for the overlay and overlayhighlight images. |
TextColors | The text colors for each button state. |
TexCoords | The texture coordinates for each button state. |
TexSlices | Slice of the associated Ui Texture to display. |
OverlayTexCoords | The texture coordinates for each button state. |
AnimatedImages | The names of AnimatedImage windows to be used as top-level overlays for the various button states. |
ResizeImages | The names of resize images to be used for the various button states. |
Allows you to display a horizontal mirror image of the button textures. This swaps the topleft and bottom left coordinates with those used for the topright and bottomright of the button.
A boolean value.
”true” | Mirror the texture coordinates |
”false” | Use normal texture coordinates |
Name of the UI Texture to use for the background image layer.
A string value, which is the name of a valid UI texture.
Name of the UI Texture to use for the overlay image layer.
A string value, which is the name of a valid UI texture.
The text alignment.
A string value, which is one of the following:
”left” | Aligned to the left. |
”top” | Centered horizontally. |
”center” | Centered horizontally (and vertically when autoresize is false). |
”right” | Aligned to the right. |
”leftcenter” | Aligned to the left and centered vertically. |
”rightcenter” | Aligned to the right and centered vertically. |
”bottom” | Aligned to the bottom and centered horizontally |
”bottomleft” | Aligned to the bottom and left. |
”bottomright” | Aligned to the bottom and right. |
An override value for the font line spacing.
Should the height of the button be automatically resized according to it’s text?
The word “true” or “false”
Auto-resize should be used with text-only, horizontal resize, or full resize buttons.
Should the width be shrunk automatically to fit it’s text?
The word “true” or “false”
When auto-resizing the width of a button, the button will only size up to it’s specified dimensions. This attribute only reduces the size when the full width is not needed.
If the text min scale value is set to something other than 1.0, the Label Button automatically drop the point size of the font on a non-re sizable Button until the text fits within the Button’s text dimensions, up to the min font scale.
The scale of the texture to be used for the button artwork. This is multiplied by the button’s <Size> to determine the texture dimensions.
A number value. (1.0 = 100%)
You can specify either a texture scale or override it with a <TexDimensions> element.
This flag allow you to specify the draw order for the button. You can elect to place child windows below or above the text/highlight button components.
A boolean value.
”true” | Draw any children before drawing highlight and text. |
”false” | Draw any children after drawing highlight and text. |
none
Should this Button log warning messages if the text is cut off?
When drawing this button, should the highlight state be drawn over-top the background image?
The offset for the text within the button dimensions. This allows you restrict the button text to only the center portion.
<TextOffset x="5" y="10" />
x | The x-pixel offset from the top left corner. |
y | The y-pixel offset from the top left corner. |
x | 0 |
y | 0 |
The offset for the overlay and overlayhighlight images. This allows you use overlays that are smaller or larger than the background images.
<OverlayOffset x="5" y="10" />
x | The x-pixel offset from the top left corner. |
y | The y-pixel offset from the top left corner. |
x | 0 |
y | 0 |
The text colors for each button state.
<TextColors>
<Normal r="255" g="204" b="102" />
<NormalHighlit r="255" g="85" b="0" />
<Pressed r="255" g="85" b="0" />
<PressedHighlit r="255" g="85" b="0"/>
<Disabled r="92" g="92" b="92" />
<DisabledPressed r="92" g="92" b="92" />
</TextColors>
r | The red color value |
g | The green color value |
b | The blue color value |
For all button states.
r | 255 |
g | 255 |
b | 255 |
The texture coordinates for each button state. The texture field is optional if you have set the backgroundtexture and highlighttexture attributes.
<TexCoords>
<Normal texture="" x="474" y="6" />
<NormalHighlit texture="" x="474" y="45" />
<Pressed texture="" x="474" y="45" />
<PressedHighlit texture="" x="474" y="45" />
<Disabled texture="" x="474" y="6" />
<DisabledPressed texture="" x="474" y="6" />
</TexCoords>
texture | The name of the UI Texture to use for this button state. |
x | The x texture coordinate. |
y | The y texture coordinate. |
For all button states.
texture | ”” |
x | 0 |
y | 0 |
Slice of the associated Ui Texture to display. The texture field is optional if you have set the backgroundtexture and highlighttexture attributes.
<TexSlices>
<Normal texture="" id="Bag-Button" />
<NormalHighlit texture="" id="Bag-Button-Highlighted" />
<Pressed texture="" id="Bag-Button-Selected" />
<PressedHighlit texture="" id="Bag-Button-Highlighted" />
<Disabled texture="" id="Bag-Button" />
<DisabledPressed texture="" id="Bag-Button" />
</TexSlices>
texture | The name of the UI Texture to use for this button state. |
id | The id of the slice of the associated Ui Texture to display. |
For all button states.
texture | ”” |
id | ”” |
The texture coordinates for each button state. The texture field is optional if you have set the overlaytexture and overlayhighlighttexture attributes.
<OverlayTexCoords>
<Normal texture="" x="474" y="6" />
<NormalHighlit texture="" x="474" y="45" />
<Pressed texture="" x="474" y="45" />
<PressedHighlit texture="" x="474" y="45" />
<Disabled texture="" x="474" y="6" />
<DisabledPressed texture="" x="474" y="6" />
</OverlayTexCoords>
texture | The name of the UI Texture to use for this button state. |
x | The x texture coordinate. |
y | The y texture coordinate. |
For all button states.
texture | ”” |
x | 0 |
y | 0 |
The names of AnimatedImage windows to be used as top-level overlays for the various button states.
<AnimatedImages>
<Normal def="DefaultAnimatedImageNormal" />
<NormalHighlit def="DefaultAnimatedImageNormalHightlite" />
<Pressed def="DefaultAnimatedImagePressed" />
<PressedHighlit def="DefaultAnimatedImagePressedHightlite" />
<Disabled def="" />
<DisabledPressed def="" />
</AnimatedImages>
def | The name of the AnimatedImage to use for this button state. |
For all button states.
def | ”” |
The names of resize images to be used for the various button states. This allows you to create buttons based on any of the resizable window types.
<ResizeImages>
<Normal def="DefaultHorizResizeButtonNormal" />
<NormalHighlit def="DefaultHorizResizeButtonHightlite" />
<Pressed def="DefaultHorizResizeButtonPressed" />
<PressedHighlit def="DefaultHorizResizeButtonPressedHightlite" />
<Disabled def="DefaultHorizResizeButtonDisabled" />
<DisabledPressed def="DefaultHorizResizeButtonDisabled" />
</ResizeImages>
def | The name of the resize image to use for this button state. |
For all button states.
def | ”” |
Functions | |
ButtonSetText() | Sets the text displayed on the button |
ButtonGetText() | Returns the text currently displayed on the button. |
ButtonSetPressedFlag() | Sets if button should display it’s ‘pressed’ state. |
ButtonGetPressedFlag() | Returns if button is currently pressed. |
ButtonSetHighlightFlag() | Sets if button should be highlighted. |
ButtonGetHighlightFlag() | Sets if button should be highlighted. |
ButtonSetDisabledFlag() | Sets if button is disabled. |
ButtonGetDisabledFlag() | Returns if the button is currently set to disabled. |
ButtonSetStayDownFlag() | Sets if button if the button should remained pressed when the user release the left mouse button. |
ButtonGetStayDownFlag() | Returns if a button is currently set to ‘stay down’ when pressed. |
ButtonSetCheckButtonFlag() | Sets if the button should behave like a check button. |
ButtonGetCheckButtonFlag() | Returns if the button is currently behaving like a check button. |
ButtonStartFlash() | Starts a scriped flash animation with the highlighted image. |
ButtonStopFlash() | Stops an active flash animation. |
ButtonSetTexture() | Sets the texture used for a particular button state. |
ButtonSetTextColor() | Sets the text color used for a particular button state. |
ButtonGetTextDimensions() | Returns the the current text dimensions. |
Sets the text displayed on the button
buttonName | (string) The name of the button. |
text | (wstring) The text string. |
nil | no return value |
ButtonSetText("InteractionWindowQuestAccept", GetString( StringTables.Default.LABEL_ACCEPT ))
Returns the text currently displayed on the button.
buttonName | (string) The name of the button. |
text | (wstring) The text string. |
local currText = ButtonGetText( name )
Sets if button should display it’s ‘pressed’ state.
buttonName | (string) The name of the button. |
isPressed | (boolean) Should the pressed state be set? |
nil | no return value |
ButtonSetPressedFlag( "SettingsResolutionUseFullscreenButton", SystemData.Settings.Resolution.useFullScreen )
Returns if button is currently pressed.
buttonName | (string) The name of the button. |
isPressed | (boolean)Is the button currently pressed? |
SystemData.Settings.Resolution.useFullScreen = ButtonGetPressedFlag( "SettingsResolutionUseFullscreenButton" )
Sets if button should be highlighted.
buttonName | (string) The name of the button. |
isHighlighted | (boolean) Should the highlighted state be set? |
nil | no return value |
ButtonSetHighlightFlag( "SomeButton", true )
Sets if button should be highlighted.
buttonName | (string) The name of the button. |
isHighlighted | (boolean) Is the button currently highlighted? |
local isHighlighted = ButtonGetHighlightFlag( "SomeButton" )
Sets if button is disabled. When disabled, the button will display it’s ‘disabled’ artwork and never highlight images.
buttonName | (string) The name of the button. |
isDisabled. | (boolean) Should the button be disabled? |
nil | no return value |
ButtonSetDisabledFlag("GroupMenuWindowGroupKickButton", GameData.Player.isGroupLeader == false )
Returns if the button is currently set to disabled.
buttonName | (string) The name of the button. |
isDisabled. | (boolean) Is the button currently disabled? |
local isDisabled = ButtonSetDisabledFlag("GroupMenuWindowGroupKickButton" )
Sets if button if the button should remained pressed when the user release the left mouse button.
buttonName | (string) The name of the button. |
stayDown | (boolean) Should the button stay down when pressed? |
nil | no return value |
ButtonSetStayDownFlag( ChatWindow.Tabs[index].tabButton, true )
Returns if a button is currently set to ‘stay down’ when pressed.
buttonName | (string) The name of the button. |
stayDown | (boolean) Does the button stay down when pressed? |
local stayDown = ButtonGetStayDownFlag( "SomeWindow" )
Sets if the button should behave like a check button. When set, the button will toggle between pressed and unpressed with each click.
buttonName | (string) The name of the button. |
isCheckButton | (boolean) Should the button behave like a check button? |
nil | no return value |
ButtonSetCheckButtonFlag( "SettingsResolutionUseFullscreenButton", true )
Returns if the button is currently behaving like a check button.
buttonName | (string) The name of the button. |
isCheckButton | (boolean) Is the button behaving like a check button? |
local isCheckButton = ButtonGetCheckButtonFlag( "SettingsResolutionUseFullscreenButton" )
Starts a scriped flash animation with the highlighted image.
buttonName | (string) The name of the button. |
flashDuration | (string) The duration to flash the button (in seconds). |
flashFrequency | (string) How frequently the flash should occur (in seconds). |
nil | no return value |
ButtonStartFlash("SomeButton", 10, 0.5);
Stops an active flash animation.
buttonName | (string) The name of the button. |
nil | no return value |
ButtonStopFlash("SomeButton")
Sets the texture used for a particular button state.
buttonName | (string) The name of the button. |
buttonState | (number) The button state to set, see <Button State> for valid values. |
textureName | (string) The name of the ui Texture to use. |
x | (number) The x coordinate within the texture. |
y | (number) The y coordinate within the texture. |
nil | no return value |
ButtonSetTexture("SomeButton", Button.ButtonState.NORMAL, "texture_name", 156, 40);
Sets the text color used for a particular button state.
buttonName | (string) The name of the button. |
buttonState | (number) The button state to set, see <Button State> for valid values. |
r | (number) The red value for the text color. |
g | (number) The green value for the text color. |
b | (number) The blue value for the text color. |
nil | no return value |
ButtonSetTextColor("SomeButton", Button.ButtonState.NORMAL, 255, 0, 255);
Returns the the current text dimensions.
buttonName | (string) The name of the button. |
x | (number) The width of the current text |
y | (number) The height of the current text |
local x, y = ButtonGetTextDimensions("SomeWindow")