Quantcast

Fix modified special keys, like dash and backslash

James Whitehead II [10-24-10 - 18:51]
Fix modified special keys, like dash and backslash
Filename
Clique.lua
Utils.lua
diff --git a/Clique.lua b/Clique.lua
index 2dd68c0..36c8dce 100755
--- a/Clique.lua
+++ b/Clique.lua
@@ -440,14 +440,8 @@ function addon:GetBindingAttributes(global)
                 end
             else
                 -- This is a key binding, so we need a binding for it
-                local prefix, suffix = addon:GetBindingPrefixSuffix(entry, global)
-                local key = entry.key
-
-                if key == "DASH" then
-                    key = "-"
-                elseif key == "BACKSLASH" then
-                    key = "\\"
-                end
+                local prefix, suffix = self:GetBindingPrefixSuffix(entry, global)
+                local key = self:ConvertSpecialKeys(entry)

                 set[#set + 1] = B_SET:format(key, suffix)
                 clr[#clr + 1] = B_CLR:format(key)
diff --git a/Utils.lua b/Utils.lua
index 706662a..d432f3e 100644
--- a/Utils.lua
+++ b/Utils.lua
@@ -264,6 +264,21 @@ function addon:GetBindingInfoText(binding)
     end
 end

+function addon:ConvertSpecialKeys(binding)
+    if type(binding) ~= "table" or not binding.key then
+        return "UNKNOWN"
+    end
+
+    local mods, key = binding.key:match("^(.-)([^%-]+)$")
+    if key == "DASH" then
+        key = "-"
+    elseif key == "BACKSLASH" then
+        key = "\\"
+    end
+
+    return tostring(mods) .. tostring(key)
+end
+
 function addon:GetBindingPrefixSuffix(binding, global)
     if type(binding) ~= "table" or not binding.key then
         return "UNKNOWN", "UNKNOWN"