WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Click cast on oUF raid frames (https://www.wowinterface.com/forums/showthread.php?t=57290)

siweia 07-14-19 10:47 PM

Click cast on oUF raid frames
 
Lua Code:
  1. local wheelBindingIndex = {
  2.     ["MOUSEWHEELUP"] = 6,
  3.     ["ALT-MOUSEWHEELUP"] = 7,
  4.     ["CTRL-MOUSEWHEELUP"] = 8,
  5.     ["SHIFT-MOUSEWHEELUP"] = 9,
  6.     ["MOUSEWHEELDOWN"] = 10,
  7.     ["ALT-MOUSEWHEELDOWN"] = 11,
  8.     ["CTRL-MOUSEWHEELDOWN"] = 12,
  9.     ["SHIFT-MOUSEWHEELDOWN"] = 13,
  10. }
  11.  
  12. local onEnterString = "self:ClearBindings();"
  13. local onLeaveString = onEnterString
  14. for keyString, keyIndex in pairs(wheelBindingIndex) do
  15.     onEnterString = format("%sself:SetBindingClick(0, \"%s\", self:GetName(), \"Button%d\");", onEnterString, keyString, keyIndex)
  16. end
  17.  
  18. local function setupMouseWheelCast(self)
  19.     local found
  20.     for _, data in pairs(NDuiDB["RaidClickSets"]) do
  21.         local key = unpack(data)
  22.         if strmatch(key, L["Wheel"]) then
  23.             found = true
  24.             break
  25.         end
  26.     end
  27.  
  28.     if found then
  29.         self:SetAttribute("clickcast_onenter", onEnterString)
  30.         self:SetAttribute("clickcast_onleave", onLeaveString)
  31.     end
  32. end
  33.  
  34. local function setupClickSets(self)
  35.     if self.clickCastRegistered then return end
  36.  
  37.     setupMouseWheelCast(self)
  38.  
  39.     for _, data in pairs(NDuiDB["RaidClickSets"]) do
  40.         local key, modKey, value = unpack(data)
  41.         if key == KEY_BUTTON1 and modKey == "SHIFT" then self.focuser = true end
  42.  
  43.         for _, v in ipairs(keyList) do
  44.             if v[1] == key and v[2] == modKey then
  45.                 if tonumber(value) then
  46.                     local name = GetSpellInfo(value)
  47.                     self:SetAttribute(format(v[3], "type"), "spell")
  48.                     self:SetAttribute(format(v[3], "spell"), name)
  49.                 elseif value == "target" then
  50.                     self:SetAttribute(format(v[3], "type"), "target")
  51.                 elseif value == "focus" then
  52.                     self:SetAttribute(format(v[3], "type"), "focus")
  53.                 elseif value == "follow" then
  54.                     self:SetAttribute(format(v[3], "type"), "macro")
  55.                     self:SetAttribute(format(v[3], "macrotext"), "/follow mouseover")
  56.                 elseif strmatch(value, "/") then
  57.                     self:SetAttribute(format(v[3], "type"), "macro")
  58.                     self:SetAttribute(format(v[3], "macrotext"), value)
  59.                 end
  60.                 break
  61.             end
  62.         end
  63.     end
  64.  
  65.     self:RegisterForClicks("AnyDown")
  66.     self:UnregisterEvent("PLAYER_REGEN_ENABLED", setupClickSets)
  67.  
  68.     self.clickCastRegistered = true
  69. end
  70.  
  71. local function CreateClickSets(self)
  72.     if InCombatLockdown() then
  73.         self:RegisterEvent("PLAYER_REGEN_ENABLED", setupClickSets, true)
  74.     else
  75.         setupClickSets(self)
  76.     end
  77. end

I'm currently using the code above to setup clickcast on raidframes.
But the "self:ClearBindings();" seems like not functioning well lately.
Do mousewheel would bind to a random raid unit button, and override my mousewheel camera zooming.
The only solution is an UI reload.
Anything I can do to avoid this?

siweia 07-31-19 07:01 AM

Lua Code:
  1. [
  2.         self:SetAttribute("clickcast_onenter", [[
  3.             self:ClearBindings()
  4.             self:SetBindingClick(1, "MOUSEWHEELUP", self, "Button6")
  5.             self:SetBindingClick(1, "ALT-MOUSEWHEELUP", self, "Button7")
  6.             self:SetBindingClick(1, "CTRL-MOUSEWHEELUP", self, "Button8")
  7.             self:SetBindingClick(1, "SHIFT-MOUSEWHEELUP", self, "Button9")
  8.             self:SetBindingClick(1, "MOUSEWHEELDOWN", self, "Button10")
  9.             self:SetBindingClick(1, "ALT-MOUSEWHEELDOWN", self, "Button11")
  10.             self:SetBindingClick(1, "CTRL-MOUSEWHEELDOWN", self, "Button12")
  11.             self:SetBindingClick(1, "SHIFT-MOUSEWHEELDOWN", self, "Button13")
  12.         ]])
  13.         self:SetAttribute("clickcast_onleave", [[
  14.             self:ClearBindings()
  15.         ]])

When I mouseover an unit button, and then the group changes before I do "onleave". (eg. someone leaves the party)
This action causes the issue I mentioned above, which override my camera zooming.
Is there any "onhide" attribute on the oUF raidframes, that I can "clearbindings"?

siweia 07-31-19 10:14 PM

Never mind, I figured it out myself.
Add a new template to ouf.lua "SecureHandlerShowHideTemplate".
Lua Code:
  1. self:SetAttribute("_onshow", "self:ClearBindings();");
  2.         self:SetAttribute("_onhide", "self:ClearBindings();");


All times are GMT -6. The time now is 03:47 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI