changeset 186:77858d975df6

Fix showgrid for action buttons in combat. HasAction() isn't updated prior to ACTIONBAR_HIDEGRID being fired, so capture drags and clicks and assume that HasAction() will report true immediately afterward.
author Flick <flickerstreak@gmail.com>
date Thu, 11 Nov 2010 10:22:36 -0800
parents 2e7a322e0195
children 6341ab2be68b
files classes/ActionButton.lua
diffstat 1 files changed, 24 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/classes/ActionButton.lua	Fri Oct 22 23:48:02 2010 +0000
+++ b/classes/ActionButton.lua	Thu Nov 11 10:22:36 2010 -0800
@@ -88,15 +88,23 @@
 
 local _childupdate_showgrid = -- function(self, snippetid, message)
 [[
+  showgrid_event = message
   self:SetAttribute("showgrid-event",message)
   if not self:GetAttribute("showgrid") then
     local count = message + (self:GetAttribute("showgrid-temp") or 0)
     if count <= 0 then
       local action = self:GetAttribute("action")
-      if HasAction(action) then
-        self:Show()
-      else
-        self:Hide()
+        -- note that HasAction is not updated on the target of a drag until after ACTIONBAR_HIDEGRID
+        -- so, we set a flag for this button in pre-click/receive-drag and check for it here
+      if HasAction(action) or self:GetAttribute("showgrid-clicked") then
+        if not self:IsShown() then
+          self:Show()
+        end
+        self:SetAttribute("showgrid-clicked",false)
+      else 
+        if self:IsShown() then
+          self:Hide()
+        end
       end
     else
       self:Show()
@@ -118,10 +126,21 @@
   if kind ~= "spell" and kind ~= "item" and kind ~= "macro" then
     return kind, value, ...
   else
+    if showgrid_event and showgrid_event > 0 then
+      self:SetAttribute("showgrid-clicked",true)
+    end
     return "action", self:GetAttribute("action")
   end
 ]]
 
+local _onClick = -- function(self, button, down)
+[[
+  if showgrid_event and showgrid_event > 0 then
+    self:SetAttribute("showgrid-clicked",true)
+  end
+  return button
+]]
+
 --
 -- private
 --
@@ -206,6 +225,7 @@
   f:SetAttribute("_childupdate-showgrid",_childupdate_showgrid)
   barFrame:WrapScript(f, "OnDragStart", _onDragStart)
   barFrame:WrapScript(f, "OnReceiveDrag", _onReceiveDrag)
+  barFrame:WrapScript(f, "OnClick", _onClick)
 
   -- attach to skinner
   bar:SkinButton(self)