Lua Code:
local wheelBindingIndex = {
["MOUSEWHEELUP"] = 6,
["ALT-MOUSEWHEELUP"] = 7,
["CTRL-MOUSEWHEELUP"] = 8,
["SHIFT-MOUSEWHEELUP"] = 9,
["MOUSEWHEELDOWN"] = 10,
["ALT-MOUSEWHEELDOWN"] = 11,
["CTRL-MOUSEWHEELDOWN"] = 12,
["SHIFT-MOUSEWHEELDOWN"] = 13,
}
local onEnterString = "self:ClearBindings();"
local onLeaveString = onEnterString
for keyString, keyIndex in pairs(wheelBindingIndex) do
onEnterString = format("%sself:SetBindingClick(0, \"%s\", self:GetName(), \"Button%d\");", onEnterString, keyString, keyIndex)
end
local function setupMouseWheelCast(self)
local found
for _, data in pairs(NDuiDB["RaidClickSets"]) do
local key = unpack(data)
if strmatch(key, L["Wheel"]) then
found = true
break
end
end
if found then
self:SetAttribute("clickcast_onenter", onEnterString)
self:SetAttribute("clickcast_onleave", onLeaveString)
end
end
local function setupClickSets(self)
if self.clickCastRegistered then return end
setupMouseWheelCast(self)
for _, data in pairs(NDuiDB["RaidClickSets"]) do
local key, modKey, value = unpack(data)
if key == KEY_BUTTON1 and modKey == "SHIFT" then self.focuser = true end
for _, v in ipairs(keyList) do
if v[1] == key and v[2] == modKey then
if tonumber(value) then
local name = GetSpellInfo(value)
self:SetAttribute(format(v[3], "type"), "spell")
self:SetAttribute(format(v[3], "spell"), name)
elseif value == "target" then
self:SetAttribute(format(v[3], "type"), "target")
elseif value == "focus" then
self:SetAttribute(format(v[3], "type"), "focus")
elseif value == "follow" then
self:SetAttribute(format(v[3], "type"), "macro")
self:SetAttribute(format(v[3], "macrotext"), "/follow mouseover")
elseif strmatch(value, "/") then
self:SetAttribute(format(v[3], "type"), "macro")
self:SetAttribute(format(v[3], "macrotext"), value)
end
break
end
end
end
self:RegisterForClicks("AnyDown")
self:UnregisterEvent("PLAYER_REGEN_ENABLED", setupClickSets)
self.clickCastRegistered = true
end
local function CreateClickSets(self)
if InCombatLockdown() then
self:RegisterEvent("PLAYER_REGEN_ENABLED", setupClickSets, true)
else
setupClickSets(self)
end
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?