flickerstreak@122: -- flickerstreak@122: -- A hack for a ShowGrid secure handler, using a bastardized Blizzard ActionBarButton. flickerstreak@122: -- flickerstreak@122: local gridProxy = { } flickerstreak@122: ReAction.gridProxy = gridProxy flickerstreak@122: flickerstreak@122: local f = CreateFrame("CheckButton",nil,UIParent,"ActionBarButtonTemplate, SecureHandlerAttributeTemplate") flickerstreak@122: -- SecureHandlerAttributeTemplate overwrites the onAttributeChanged handler, as it's last in the list flickerstreak@122: f:UnregisterAllEvents() flickerstreak@122: f:SetScript("OnEnter",nil) flickerstreak@122: f:SetScript("OnLeave",nil) flickerstreak@122: f:SetScript("PostClick",nil) flickerstreak@122: f:SetScript("OnDragStart",nil) flickerstreak@122: f:SetScript("OnReceiveDrag",nil) flickerstreak@122: f:SetScript("OnUpdate",nil) flickerstreak@122: f:EnableMouse(false) flickerstreak@122: for _, child in ipairs({f:GetChildren()}) do flickerstreak@122: child:Hide() flickerstreak@122: end flickerstreak@122: for _, region in ipairs({f:GetRegions()}) do flickerstreak@122: region:Hide() flickerstreak@122: end flickerstreak@122: f:SetPoint("TOPLEFT") flickerstreak@122: f:Hide() flickerstreak@122: flickerstreak@122: -- The existing onEvent handler will set the 'showgrid' attribute flickerstreak@122: -- on this frame. Re-register for those events, but don't touch the flickerstreak@122: -- onEvent handler, to keep it secure. flickerstreak@122: f:RegisterEvent("ACTIONBAR_SHOWGRID"); flickerstreak@122: f:RegisterEvent("ACTIONBAR_HIDEGRID"); flickerstreak@122: flickerstreak@122: f:Execute( flickerstreak@122: [[ flickerstreak@122: frames = newtable() flickerstreak@122: ]]) flickerstreak@122: flickerstreak@122: -- shuttle 'showgrid' to the registered frames via state-showgrid attribute flickerstreak@122: f:SetAttribute("_onattributechanged", flickerstreak@122: -- function _onattributechanged(self,name,value) flickerstreak@122: [[ flickerstreak@122: if name == "showgrid" then flickerstreak@122: for _, f in pairs(frames) do flickerstreak@122: f:SetAttribute("state-showgrid",value) flickerstreak@122: end flickerstreak@122: end flickerstreak@122: ]]) flickerstreak@122: flickerstreak@122: function gridProxy:AddFrame(frame) flickerstreak@122: f:SetFrameRef("add",frame) flickerstreak@122: f:SetAttribute("frame-add-id",frame:GetName()) flickerstreak@122: f:Execute( flickerstreak@122: [[ flickerstreak@122: frames[self:GetAttribute("frame-add-id")] = self:GetFrameRef("add") flickerstreak@122: ]]) flickerstreak@122: end flickerstreak@122: flickerstreak@122: function gridProxy:RemoveFrame(frame) flickerstreak@122: f:SetAttribute("frame-remove-id",frame:GetName()) flickerstreak@122: f:Execute( flickerstreak@122: [[ flickerstreak@122: frames[self:GetAttribute("frame-remove-id")] = nil flickerstreak@122: ]]) flickerstreak@122: end flickerstreak@122: flickerstreak@122: