m
clean up, typos fixed: the exact same → exactly the same
m (clean up, typos fixed: the exact same → exactly the same) |
|||
| Line 15: | Line 15: | ||
You can reference the name of your Check Box either by writing it explicitly, or by making a function call. Writing it explicitly "looks prettier", but might be confusing to anyone looking at your code, as the name for it seems made-up. Note arg2 in the creation call. It is the same as what is below, but we have appended it with "Text". This is necessary, I don't know why they didn't just set it up so you can do myCheckButton:Text, but we must work with what we're given. | You can reference the name of your Check Box either by writing it explicitly, or by making a function call. Writing it explicitly "looks prettier", but might be confusing to anyone looking at your code, as the name for it seems made-up. Note arg2 in the creation call. It is the same as what is below, but we have appended it with "Text". This is necessary, I don't know why they didn't just set it up so you can do myCheckButton:Text, but we must work with what we're given. | ||
myCheckButton_GlobalNameText:SetText("CheckBox Name"); | myCheckButton_GlobalNameText:SetText("CheckBox Name"); | ||
Here is the code to do the | Here is the code to do exactly the same thing, but it's not explicitly written. This is (arguably) less confusing. | ||
getglobal(myCheckButton:GetName() .. 'Text'):SetText("CheckBox Name"); | getglobal(myCheckButton:GetName() .. 'Text'):SetText("CheckBox Name"); | ||
| Line 44: | Line 44: | ||
== Recommendation == | == Recommendation == | ||
However, I recommend creating a generic "checkbox-factory function", like this: | However, I recommend creating a generic "checkbox-factory function", like this: | ||
| Line 57: | Line 57: | ||
return checkbutton; | return checkbutton; | ||
end | end | ||
myCheckButton = bw_addon.createCheckbutton(UIParent, 400, -600 "A Checkbox"); | myCheckButton = bw_addon.createCheckbutton(UIParent, 400, -600 "A Checkbox"); | ||