-
Notifications
You must be signed in to change notification settings - Fork 26
Window
There are 3 components here:
StdUi:Window(parent, width, height, title)
Description:
Simple draggable Window
with close button. Clamped to screen by default.
WARNING: You need to set point yourself to make it visible**
Arguments:
-
parent
Frame - object that should be a parent, useUIParent
ornil
to make it global. -
width
number - Width of the window -
height
number - Height of the window -
title
string - String that will be displayed as window title
Methods:
Window has all methods that normal Frame
has plus:
-
SetWindowTitle(text)
- Sets the new window title.
Warning: Please do not set script
OnClick
oncloseBtn
because it will no longer hide window, useHookScript
instead.
Named children:
-
titlePanel
- Frame - frame that is used as widnow title panel -
titlePanel.label
- FontString - font string that is used as window label -
closeBtn
- Button - Close button
Returns:
StdUi:Dialog(title, message, dialogId)
Description:
Dialog is very similar to Window
, except it automatically sets point to 'CENTER'
and shows it.
It also has messageLabel
in the middle of it.
Plus if you set dialogId
parameter, it will reuse previously created frame.
All dialogs are contained in StdUi.dialogs
table.
Arguments:
-
title
string - Dialog title string -
message
number - Message to be displayed in dialog center, supports colors -
dialogId
number - Unique dialog identifier. Calling method twice with the same dialogId will reuse previously created frame
Named children:
-
messageLabel
- FontString - font string that is used as dialog message
StdUi:Confirm(title, message, buttons, dialogId)
Description:
Confirm
is basically Dialog
that additionally has buttons which you can define.
Arguments:
-
title
string - Confirm title string -
message
number - Message to be displayed in confirm center, supports colors -
buttons
table - Table of button definition -
dialogId
number - Unique confirm identifier. Calling method twice with the same dialogId will reuse previously created frame.
WARNING:
dialogId
is shared betweenConfirm
andDialog
Button definition:
{
buttonId = {
text = 'button text',
onClick = function() end
}
}
Example:
local buttons = {
ok = {
text = 'OK',
onClick = function(b)
b.window:Hide(); -- This is how you can get from button script handler to dialog window itself
end
},
cancel = {
text = 'Cancel',
onClick = function()
end
}
}
Named children:
-
buttons
- Array of Frame - button frames
Returns:
local StdUi = LibStub('StdUi');
local window = StdUi:Window(UIParent, 500, 500, 'Title');
window:SetPoint('CENTER');
local b1 = StdUi:Button(window, 100, 20, 'Dialog');
b1:SetScript('OnClick', function ()
StdUi:Dialog('Dialog title', 'Some simple dialog message with ' ..
WrapTextInColorCode('Color', 'ff0000ff') .. ' support', 'uniqueDialogId');
end);
local buttons = {
ok = {
text = OKAY,
onClick = function(b)
print('OK');
b.window:Hide(); -- This is how you can get from button script handler to dialog window itself
end
},
cancel = {
text = CANCEL,
onClick = function(b)
print('cancel');
b.window:Hide();
end
}
}
local b2 = StdUi:Button(window, 100, 20, 'Confirm');
b2:SetScript('OnClick', function ()
StdUi:Confirm('Dialog title', 'Do you confirm?', buttons, 'uniqueConfirmId');
end);
b1:SetPoint('CENTER');
StdUi:GlueBelow(b2, b1);