annotate OOCDo.lua @ 6:0a7fd4d73d30

newer commands use more types, so reset type in posthook when emptying button
author rowaasr13
date Tue, 10 Jan 2017 19:38:52 +0300
parents 56099742e29b
children e41de98f6b33
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@2 21 function button.MacroText(command, command2)
rowaasr13@0 22 if command == button then command = command2 end
rowaasr13@0 23 if InCombatLockdown() then return end
rowaasr13@0 24 button:SetAttribute("macrotext", command)
rowaasr13@0 25 end
rowaasr13@0 26
rowaasr13@0 27 button.Macro = button.MacroText
rowaasr13@0 28 button.T = button.MacroText
rowaasr13@0 29 button.M = button.MacroText