From 892ef154b0c9bc0909de07ff4fbf1825a30025c3 Mon Sep 17 00:00:00 2001 From: shagu Date: Sat, 3 Oct 2020 14:57:56 +0200 Subject: [PATCH] ui-widgets: use onupdate to determine button state --- api/ui-widgets.lua | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/api/ui-widgets.lua b/api/ui-widgets.lua index 45bc2014..8159fbce 100644 --- a/api/ui-widgets.lua +++ b/api/ui-widgets.lua @@ -763,23 +763,19 @@ function pfUI.api.SkinArrowButton(button, dir, size) button.icon:SetTexture(pfUI.media["img:"..dir]) - if not button.pfScripted then - RunOOC(function() - local enable = button.Enable - local disable = button.Disable + if not button.pficonfade then + local button, state = button, nil + button.pficonfade = CreateFrame("Frame", nil, button) + button.pficonfade:SetScript("OnUpdate", function() + if state == button:IsEnabled() then return end + state = button:IsEnabled() - button.Enable = function(self) - if enable then enable(self) end - self.icon:SetVertexColor(.8,.8,.8,1) - end - - button.Disable = function(self) - if disable then disable(self) end - self.icon:SetVertexColor(.2,.2,.2,1) + if state > 0 then + button.icon:SetVertexColor(.8,.8,.8,1) + else + button.icon:SetVertexColor(.2,.2,.2,1) end end) - - button.pfScripted = true end end