.MacroText: explicitly set button type, as newer commands could change it to something else; luadoc.
author |
rowaasr13 |
date |
Tue, 10 Jan 2017 19:39:55 +0300 |
parents |
0a7fd4d73d30 |
children |
3b9bc71a1dd6 |
rev |
line source |
rowaasr13@0
|
1 -- [AUTOLOCAL START]
|
rowaasr13@0
|
2 local CreateFrame = CreateFrame
|
rowaasr13@0
|
3 local InCombatLockdown = InCombatLockdown
|
rowaasr13@0
|
4 local SecureHandlerWrapScript = SecureHandlerWrapScript
|
rowaasr13@0
|
5 local print = print
|
rowaasr13@0
|
6 local type = type
|
rowaasr13@0
|
7 -- [AUTOLOCAL END]
|
rowaasr13@0
|
8
|
rowaasr13@0
|
9 local frame_name = "OOCDo"
|
rowaasr13@0
|
10 local button = CreateFrame("Button", frame_name, nil, "SecureActionButtonTemplate,SecureHandlerMouseUpDownTemplate")
|
rowaasr13@0
|
11 button:SetAttribute("type", "macro")
|
rowaasr13@0
|
12 button:SetAttribute("macrotext", "")
|
rowaasr13@0
|
13 SecureHandlerWrapScript(
|
rowaasr13@0
|
14 button, -- frame
|
rowaasr13@0
|
15 "OnClick", -- script
|
rowaasr13@0
|
16 button, -- header
|
rowaasr13@6
|
17 'return nil, "reset"', -- pre
|
rowaasr13@6
|
18 'self:SetAttribute("type", "macro") self:SetAttribute("macrotext", "")' -- post
|
rowaasr13@0
|
19 )
|
rowaasr13@0
|
20
|
rowaasr13@7
|
21 --- Sets button to perform given macro text as-is.
|
rowaasr13@7
|
22 -- Sets button's .type to "macro" and .macrotext to given string verbatim
|
rowaasr13@7
|
23 -- @param command macro text to perform
|
rowaasr13@7
|
24 -- @param command2 same as command, if first argument is "taken" because of : call.
|
rowaasr13@2
|
25 function button.MacroText(command, command2)
|
rowaasr13@0
|
26 if command == button then command = command2 end
|
rowaasr13@0
|
27 if InCombatLockdown() then return end
|
rowaasr13@7
|
28 button:SetAttribute("type", "macro")
|
rowaasr13@0
|
29 button:SetAttribute("macrotext", command)
|
rowaasr13@0
|
30 end
|
rowaasr13@0
|
31
|
rowaasr13@0
|
32 button.Macro = button.MacroText
|
rowaasr13@0
|
33 button.T = button.MacroText
|
rowaasr13@0
|
34 button.M = button.MacroText |