-
Notifications
You must be signed in to change notification settings - Fork 4
/
ui-check.lua
36 lines (26 loc) · 1.04 KB
/
ui-check.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local myname, ns = ...
local function CheckSound(self)
local sound = self:GetChecked() and 'On' or 'Off'
PlaySound('igMainMenuOptionCheckBox'.. sound)
end
-- Creates a checkbox.
-- All args optional but parent is highly recommended
function ns.NewCheckBox(parent, size, ...)
local check = CreateFrame("CheckButton", nil, parent)
check:SetWidth(size or 26)
check:SetHeight(size or 26)
if select(1, ...) then check:SetPoint(...) end
check:SetNormalTexture("Interface\\Buttons\\UI-CheckBox-Up")
check:SetPushedTexture("Interface\\Buttons\\UI-CheckBox-Down")
check:SetHighlightTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
check:SetDisabledCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check-Disabled")
check:SetCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check")
check:SetScript("PreClick", CheckSound)
return check
end
-- Creates a label next to a checkbox
function ns.NewCheckLabel(check, text)
local fs = check:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
fs:SetPoint("LEFT", check, "RIGHT", 0, 1)
fs:SetText(text)
end