From c5871ede953164a193666707d08e427ede3c88af Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Mon, 18 Oct 2010 00:17:54 +0100 Subject: [PATCH] Disable button-based hovercast/global bindings on unit frames --- Clique.lua | 23 ++++++++++++++++++----- Utils.lua | 16 ++++++++++------ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Clique.lua b/Clique.lua index d8bfa0b..a9528a2 100755 --- a/Clique.lua +++ b/Clique.lua @@ -327,7 +327,7 @@ function addon:GetClickAttributes(global) for idx, entry in ipairs(self.bindings) do if self:ShouldSetBinding(entry, global) then - local prefix, suffix = addon:GetBindingPrefixSuffix(entry) + local prefix, suffix = addon:GetBindingPrefixSuffix(entry, global) -- Set up help/harm bindings. The button value will be either a number, -- in the case of mouse buttons, otherwise it will be a string of @@ -379,7 +379,6 @@ local B_CLR = [[self:ClearBinding(%q);]] -- This function will create two attributes, the first being a "setup keybindings" -- script and the second being a "clear keybindings" script. - function addon:GetBindingAttributes(global) local set = { } @@ -404,10 +403,24 @@ function addon:GetBindingAttributes(global) for idx, entry in ipairs(self.bindings) do if self:ShouldSetBinding(entry, global) and entry.key then - if not entry.key:match("BUTTON%d+$") then + local buttonNum = entry.key:match("BUTTON%d+$") + + -- Button bindings cannot be bound in the global or hovercast + -- bind-sets. This is due to a limitation in the Blizzard API + -- and there does not appear to be any way around this + + if buttonNum and global and entry.sets.hovercast or entry.sets.global then + -- Do NOT allow re-bindings of unmodified left/right-click + if entry.key ~= "BUTTON1" and entry.key ~= "BUTTON2" then + local prefix, suffix = addon:GetBindingPrefixSuffix(entry, global) + local key = entry.key + + set[#set + 1] = B_SET:format(key, suffix) + clr[#clr + 1] = B_CLR:format(key) + end + else -- This is a key binding, so we need a binding for it - - local prefix, suffix = addon:GetBindingPrefixSuffix(entry) + local prefix, suffix = addon:GetBindingPrefixSuffix(entry, global) local key = entry.key if key == "DASH" then diff --git a/Utils.lua b/Utils.lua index 42ebd00..2880b1d 100644 --- a/Utils.lua +++ b/Utils.lua @@ -262,7 +262,7 @@ function addon:GetBindingInfoText(binding) end end -function addon:GetBindingPrefixSuffix(binding) +function addon:GetBindingPrefixSuffix(binding, global) if type(binding) ~= "table" or not binding.key then return "UNKNOWN", "UNKNOWN" end @@ -274,12 +274,16 @@ function addon:GetBindingPrefixSuffix(binding) prefix = prefix:lower() - local button = suffix:match("^BUTTON(%d+)$") - if button then - suffix = button + local prefixKey = prefix:gsub("[%A]", "") + local buttonNum = suffix:match("^BUTTON(%d+)$") + + if buttonNum and global then + suffix = "cliquemouse" .. tostring(prefixKey) .. tostring(buttonNum) + prefix = "" + elseif buttonNum then + suffix = buttonNum else - local mbid = (prefix .. suffix) - suffix = "cliquebutton" .. mbid + suffix = "cliquebutton" .. tostring(prefixKey) .. tostring(suffix) prefix = "" end -- 1.7.9.5