From 04161e1239f9d432d8d7a0a1a52058df030705ed Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Wed, 27 Aug 2014 10:12:16 +0200 Subject: [PATCH] Use a secure method of hiding the button --- Molinari.lua | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/Molinari.lua b/Molinari.lua index 490feeb..6138c0f 100644 --- a/Molinari.lua +++ b/Molinari.lua @@ -1,7 +1,15 @@ -local Molinari = CreateFrame('Button', (...), UIParent, 'SecureActionButtonTemplate, AutoCastShineTemplate') +local Molinari = CreateFrame('Button', (...), UIParent, 'SecureActionButtonTemplate, SecureHandlerStateTemplate, AutoCastShineTemplate') Molinari:SetScript('OnEvent', function(self, event, ...) self[event](self, ...) end) Molinari:RegisterEvent('PLAYER_LOGIN') +RegisterStateDriver(Molinari, 'visible', '[nomod:alt] hide; show') +Molinari:SetAttribute('_onstate-visible', [[ + if(newstate == 'hide' and self:IsShown()) then + self:ClearAllPoints() + self:Hide() + end +]]) + local LibProcessable = LibStub('LibProcessable') local scripts = {'OnClick', 'OnMouseUp', 'OnMouseDown'} @@ -19,6 +27,13 @@ local function ParentClick(self, button, ...) end end +local function OnLeave(self) + if(not InCombatLockdown()) then + self:ClearAllPoints() + self:Hide() + end +end + local function ApplyButton(itemLink, spell, r, g, b) local parent = GetMouseFocus() local slot = parent:GetID() @@ -80,35 +95,15 @@ function Molinari:PLAYER_LOGIN() end end) + self:Hide() self:RegisterForClicks('AnyUp') self:SetFrameStrata('TOOLTIP') - self:SetScript('OnLeave', self.MODIFIER_STATE_CHANGED) + self:SetScript('OnHide', AutoCastShine_AutoCastStop) + self:SetScript('OnLeave', OnLeave) self:HookScript('OnClick', ParentClick) - self:RegisterEvent('MODIFIER_STATE_CHANGED') - self:Hide() - for _, sparks in next, self.sparkles do sparks:SetHeight(sparks:GetHeight() * 3) sparks:SetWidth(sparks:GetWidth() * 3) end end - -function Molinari:MODIFIER_STATE_CHANGED(key) - if(not self:IsShown() and not key and key ~= 'LALT' and key ~= 'RALT') then return end - - if(InCombatLockdown()) then - self:SetAlpha(0) - self:RegisterEvent('PLAYER_REGEN_ENABLED') - else - self:ClearAllPoints() - self:SetAlpha(1) - self:Hide() - AutoCastShine_AutoCastStop(self) - end -end - -function Molinari:PLAYER_REGEN_ENABLED() - self:UnregisterEvent('PLAYER_REGEN_ENABLED') - self:MODIFIER_STATE_CHANGED() -end -- 1.7.9.5