+ secure:SetWidth(32);
+ secure:SetHeight(32);
+ secure.base = secure:CreateTexture(nil, "BACKGROUND");
+ secure.base:SetAllPoints();
+ secure.base:SetColorTexture(0, 0, 0, 0.5);
+ secure.iconbase = secure:CreateTexture(nil, "BORDER");
+ secure.iconbase:SetPoint("TOPLEFT", secure.base, "TOPLEFT", 1, -1);
+ secure.iconbase:SetPoint("BOTTOMRIGHT", secure.base, "BOTTOMRIGHT", -1, 1);
+ secure.iconbase:SetColorTexture(0, 0, 0, 0.5);
+ secure.iconbase:Hide();
+ secure.icon = secure:CreateTexture(nil, "ARTWORK");
+ secure.icon:SetPoint("TOPLEFT", secure.iconbase, "TOPLEFT");
+ secure.icon:SetPoint("BOTTOMRIGHT", secure.iconbase, "BOTTOMRIGHT");
+ secure.icon:SetTexCoord(0.07, 0.93, 0.07, 0.93);
+ secure.hotkey = secure:CreateFontString(nil, "OVERLAY", "NumberFontNormalGray");
+ secure.hotkey:SetPoint("TOPRIGHT", secure, "TOPRIGHT", 2, -1);
+ secure.count = secure:CreateFontString(nil, "OVERLAY", "NumberFontNormal");
+ secure.count:SetPoint("BOTTOMRIGHT", secure, "BOTTOMRIGHT", 2, -1);
+ secure.cd = CreateFrame("Cooldown", name..slot.."CD", secure, "CooldownFrameTemplate");
+ secure.cd:SetAllPoints();
+ secure:SetAttribute("type", "action");
+ secure:SetAttribute("action", slot);
+ function secure:ActionChanged()
+ return updateButton(self, slot);
+ end
+ secure:ActionChanged(); -- initial update
+ -- FrameXML/SecureHandlers.lua has arguments and return value
+ -- args: self, button, kind, value, ... (kind, value, ... from GetCursorInfo())
+ -- returns: kind, target, detail
+ -- or: "clear", kind, target, detail
+ -- used for Pickup* functions
+ -- some of these snippets based on LibActionButton-1.0
+ secure:SetAttribute("_ondragstart", [=[
+ return "action", self:GetAttribute("action");
+ ]=]);
+ secure:SetAttribute("_onreceivedrag", [=[
+ if not kind or not value then return nil end
+ return "action", self:GetAttribute("action");
+ ]=]);
+ -- pre-wrapper can pass a message to post-wrapper
+ secure:WrapScript(secure, "OnDragStart", [=[
+ local kind, value = GetActionInfo(self:GetAttribute("action"));
+ return "message", format("%s|%s", tostring(kind), tostring(value));
+ ]=], [=[
+ local kind, value = GetActionInfo(self:GetAttribute("action"));
+ if message ~= format("%s|%s", tostring(kind), tostring(value)) then
+ self:CallMethod("ActionChanged");
+ end
+ ]=]);
+ secure:WrapScript(secure, "OnReceiveDrag", [=[
+ local kind, value = GetActionInfo(self:GetAttribute("action"));
+ return "message", format("%s|%s", tostring(kind), tostring(value));
+ ]=], [=[
+ local kind, value = GetActionInfo(self:GetAttribute("action"));
+ if message ~= format("%s|%s", tostring(kind), tostring(value)) then
+ self:CallMethod("ActionChanged");
+ end
+ ]=]);
+ secure:WrapScript(secure, "OnClick", [=[
+ local kind, value = GetActionInfo(self:GetAttribute("action"));
+ return nil, format("%s|%s", tostring(kind), tostring(value));
+ ]=], [=[
+ local kind, value = GetActionInfo(self:GetAttribute("action"));
+ if message ~= format("%s|%s", tostring(kind), tostring(value)) then
+ self:CallMethod("ActionChanged");
+ end
+ ]=]);
+ buttons[slot] = secure;
+ prev = secure;
+ end