Mercurial > wow > reaction
comparison classes/ActionButton.lua @ 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 | df68b5a40490 |
| children | e63aefb8a555 |
comparison
equal
deleted
inserted
replaced
| 185:2e7a322e0195 | 186:77858d975df6 |
|---|---|
| 86 control:CallMethod("ShowVehicleExit",show) | 86 control:CallMethod("ShowVehicleExit",show) |
| 87 ]] | 87 ]] |
| 88 | 88 |
| 89 local _childupdate_showgrid = -- function(self, snippetid, message) | 89 local _childupdate_showgrid = -- function(self, snippetid, message) |
| 90 [[ | 90 [[ |
| 91 showgrid_event = message | |
| 91 self:SetAttribute("showgrid-event",message) | 92 self:SetAttribute("showgrid-event",message) |
| 92 if not self:GetAttribute("showgrid") then | 93 if not self:GetAttribute("showgrid") then |
| 93 local count = message + (self:GetAttribute("showgrid-temp") or 0) | 94 local count = message + (self:GetAttribute("showgrid-temp") or 0) |
| 94 if count <= 0 then | 95 if count <= 0 then |
| 95 local action = self:GetAttribute("action") | 96 local action = self:GetAttribute("action") |
| 96 if HasAction(action) then | 97 -- note that HasAction is not updated on the target of a drag until after ACTIONBAR_HIDEGRID |
| 97 self:Show() | 98 -- so, we set a flag for this button in pre-click/receive-drag and check for it here |
| 98 else | 99 if HasAction(action) or self:GetAttribute("showgrid-clicked") then |
| 99 self:Hide() | 100 if not self:IsShown() then |
| 101 self:Show() | |
| 102 end | |
| 103 self:SetAttribute("showgrid-clicked",false) | |
| 104 else | |
| 105 if self:IsShown() then | |
| 106 self:Hide() | |
| 107 end | |
| 100 end | 108 end |
| 101 else | 109 else |
| 102 self:Show() | 110 self:Show() |
| 103 end | 111 end |
| 104 end | 112 end |
| 116 local _onReceiveDrag = -- function(self, button, kind, value, ...) | 124 local _onReceiveDrag = -- function(self, button, kind, value, ...) |
| 117 [[ | 125 [[ |
| 118 if kind ~= "spell" and kind ~= "item" and kind ~= "macro" then | 126 if kind ~= "spell" and kind ~= "item" and kind ~= "macro" then |
| 119 return kind, value, ... | 127 return kind, value, ... |
| 120 else | 128 else |
| 129 if showgrid_event and showgrid_event > 0 then | |
| 130 self:SetAttribute("showgrid-clicked",true) | |
| 131 end | |
| 121 return "action", self:GetAttribute("action") | 132 return "action", self:GetAttribute("action") |
| 122 end | 133 end |
| 134 ]] | |
| 135 | |
| 136 local _onClick = -- function(self, button, down) | |
| 137 [[ | |
| 138 if showgrid_event and showgrid_event > 0 then | |
| 139 self:SetAttribute("showgrid-clicked",true) | |
| 140 end | |
| 141 return button | |
| 123 ]] | 142 ]] |
| 124 | 143 |
| 125 -- | 144 -- |
| 126 -- private | 145 -- private |
| 127 -- | 146 -- |
| 204 -- secure handlers | 223 -- secure handlers |
| 205 f:SetAttribute("_childupdate", _childupdate) | 224 f:SetAttribute("_childupdate", _childupdate) |
| 206 f:SetAttribute("_childupdate-showgrid",_childupdate_showgrid) | 225 f:SetAttribute("_childupdate-showgrid",_childupdate_showgrid) |
| 207 barFrame:WrapScript(f, "OnDragStart", _onDragStart) | 226 barFrame:WrapScript(f, "OnDragStart", _onDragStart) |
| 208 barFrame:WrapScript(f, "OnReceiveDrag", _onReceiveDrag) | 227 barFrame:WrapScript(f, "OnReceiveDrag", _onReceiveDrag) |
| 228 barFrame:WrapScript(f, "OnClick", _onClick) | |
| 209 | 229 |
| 210 -- attach to skinner | 230 -- attach to skinner |
| 211 bar:SkinButton(self) | 231 bar:SkinButton(self) |
| 212 | 232 |
| 213 -- initial display | 233 -- initial display |
