Quantcast

Attempt to resolve the issue with "stuck" bindings

Jim Whitehead [09-30-16 - 19:25]
Attempt to resolve the issue with "stuck" bindings

There are some situations in which the mouseover unit can go away, and
we're currently using this to detect if a frame might be obscuring the
current one or if the current frame has been hidden.

I have made this check smarter and it should be better at determining
when to clear the bindings that have been set. If you want to view more
information about when bindings are being clear (or not) you can run the
following in-game:

/run Clique.settings.debugUnitIssue = true
/reload

You can remove these messages later with the reverse:

/run Clique.settings.debugUnitIssue = false
/reload
Filename
Clique.lua
diff --git a/Clique.lua b/Clique.lua
index 270446b..fd2ff30 100755
--- a/Clique.lua
+++ b/Clique.lua
@@ -58,14 +58,21 @@ function addon:Initialize()

 	-- This snippet will clear any dangling bindings that might have occurred
 	-- as a result of frames being shown/hidden.
-    self.header:SetAttribute("_onattributechanged", [[
-        if name == "hasunit" then
-            if value == "false" and danglingButton then
+    local oacScript = [[
+        if name == "hasunit" and value == "false" and danglingButton then
+            -- Check if we should clear the bindings
+            if not danglingButton:IsUnderMouse() or not danglingButton:IsVisible() then
+                if {{debug}} then print("Clique: clearing bindings, unit lost") end
                 self:RunFor(danglingButton, self:GetAttribute("setup_onleave"))
                 danglingButton = nil
+            else
+                if {{debug}} then print("Clique: ignoring unit loss, frame still here") end
             end
         end
-    ]])
+    ]]
+    oacScript = oacScript:gsub("{{debug}}", self.settings.debugUnitIssue and "true" or "false")
+
+    self.header:SetAttribute("_onattributechanged", oacScript)
     RegisterAttributeDriver(self.header, "hasunit", "[@mouseover, exists] true; false")

 	-- Create a secure action button that's sole purpose is to cancel a