-
Notifications
You must be signed in to change notification settings - Fork 26
Buttons
pwilkowski edited this page Oct 13, 2019
·
20 revisions
StdUi has few buttons that you can use:
StdUi:HighlightButton(parent, width, height, text)
This is the simplest implementation of Button object that that does not have any backdrop. This button has just text
and highlight
. If you will not provide any text, button will be just Frame that has hover highlight.
Argument | Type | Optional | Description |
---|---|---|---|
parent |
Frame | - | Object that should be a parent of font string |
width |
number | - | Width of the button |
height |
number | - | Height of the button |
text |
string | - | String that should be on button |
Child | Type | Description |
---|---|---|
button.text |
FontString |
FontString that is used as button text |
button.highlightTexture |
Texture | Texture that is used |
local button = StdUi:HighlightButton(window, 200, 20, 'Button Text');
StdUi:Button(parent, width, height, text)
This widget is the very similar to Highlight Button except it has proper backdrop.
Argument | Type | Optional | Description |
---|---|---|---|
parent |
Frame | - | Object that should be a parent of font string |
width |
number | - | Width of the button |
height |
number | - | Height of the button |
text |
string | - | String that should be on button |
Child | Type | Description |
---|---|---|
button.text |
FontString |
FontString that is used as button text |
button.highlightTexture |
Texture | Texture that is used |
local button = StdUi:Button(window, 200, 20, 'Button Text');
StdUi:SquareButton(parent, width, height, icon)
Button with icon from this texture:
Argument | Type | Optional | Description |
---|---|---|---|
parent |
Frame | - | object that should be a parent of font string |
width |
number | - | Width of the button |
height |
number | - | Height of the button |
icon |
string | - | Which icon should be used, allowed: 'UP' , 'DOWN' , 'LEFT' , 'RIGHT' , 'DELETE'
|
Child | Type | Description |
---|---|---|
button.icon |
Texture | Texture of icon |
button.iconDisabled |
Texture | Texture of icon when button is disabled |
button.highlightTexture |
Texture | Texture that is used as highlight |
local button = StdUi:SquareButton(window, 20, 20, 'DOWN');
Since buttons are default blizzard Button
they support every possible Button method. In addition, library adds one function:
- SetFontSize(newSize) - Sets new font size without changing font or font effects
Inherited methods:
Function | Description |
---|---|
Click() |
Execute the click action of the button. |
Disable() |
Disable the Button so that it cannot be clicked. |
Enable() |
Enable to the Button so that it may be clicked. |
GetButtonState() |
Return the current state ('PUSHED', 'NORMAL') of the Button. |
GetDisabledFontObject() |
Return the font object for the Button when disabled (added 1.10) |
GetDisabledTexture() |
Get the texture for this button when disabled (added 1.11) |
GetFontString() |
Get this button's label FontString (added 1.11) |
GetHighlightFontObject() |
Return the font object for the Button when highlighted (added 1.10) |
GetHighlightTexture() |
Get the texture for this button when highlighted (added 1.11) |
GetNormalTexture() |
Get the normal texture for this button (added 1.11) |
GetNormalFontObject() |
Get the Normal Font Object of the button (added 3.0.0) |
GetPushedTextOffset() |
Get the text offset when this button is pushed (x, y) (added 1.11) |
GetPushedTexture() |
Get the texture for this button when pushed (added 1.11) |
GetText() |
Get the text label for the Button. |
GetTextHeight() |
Get the height of the Button's text. |
GetTextWidth() |
Get the width of the Button's text. |
IsEnabled() |
Determine whether the Button is enabled. |
LockHighlight() |
Set the Button to always be drawn highlighted. |
RegisterForClicks('clickType'[,'clickType'...]) |
Specify which mouse button up/down actions cause receive an OnClick notification. |
SetButtonState('state'[, lock]) |
Set the state of the Button ('PUSHED', 'NORMAL') and whether it is locked. |
SetDisabledFontObject([font]) |
Set the font object for settings when disabled (added 1.10) |
SetDisabledTexture(texture or 'texturePath') |
Set the disabled texture for the Button (updated in 1.10) |
SetFont('font', size[,'flags']) |
Set the font to use for display. |
SetFontString(fontString) |
Set the button's label FontString (added 1.11) |
SetFormattedText('formatstring'[, ...]) |
Set the formatted text label for the Button. (added 2.3) |
SetHighlightFontObject([font]) |
Set the font object for settings when highlighted (added 1.10) |
SetHighlightTexture(texture or 'texturePath'[, alphaMode]) |
Set the highlight texture for the Button (updated in 1.10) |
SetNormalTexture(texture or 'texturePath') |
Set the normal texture for the Button (updated in 1.10) |
SetNormalFontObject(FontString) |
Replaces SetTextFontObject (updated in 3.0) |
SetPushedTextOffset(x, y) |
Set the text offset for this button when pushed (added 1.11) |
SetPushedTexture(texture or 'texturePath') |
Set the pushed texture for the Button (updated in 1.10) |
SetText('text') |
Set the text label for the Button. |
UnlockHighlight() |
Set the Button to not always be drawn highlighted. |
All button functions returns normal blizzard buttons so you can use SetScript
to attach your handlers:
button:SetScript('OnClick', function()
-- Your onclick handler script
end);
local StdUi = LibStub('StdUi');
local window = StdUi:Window(nil, 400, 300, 'Title');
window:SetPoint('CENTER', 0, 0);
local hb = StdUi:HighlightButton(window, 200, 20, 'Highlight');
local b = StdUi:Button(window, 200, 20, 'Normal Button');
local sb = StdUi:SquareButton(window, 20, 20, 'DELETE');
StdUi:GlueTop(hb, window, 10, -40, 'LEFT');
StdUi:GlueBelow(b, hb, 0, -20);
StdUi:GlueBelow(sb, b, 0, -20, 'LEFT');