diff --git a/.luacheckrc b/.luacheckrc index 32a72d1..e9a3a6a 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -84,6 +84,7 @@ read_globals = { "SetBindingClick", "SetCVar", "SetModifiedClick", + "SetOverrideBinding", "SetOverrideBindingClick", "UnitClass", "UnitFactionGroup", diff --git a/PetBar.lua b/PetBar.lua index 0b9cc54..2ba29ad 100644 --- a/PetBar.lua +++ b/PetBar.lua @@ -79,11 +79,26 @@ function PetBarMod:ReassignBindings() if InCombatLockdown() then return end if not self.bar or not self.bar.buttons then return end ClearOverrideBindings(self.bar) - for i = 1, 10 do - local button, real_button = ("BONUSACTIONBUTTON%d"):format(i), ("BT4PetButton%d"):format(i) - for k=1, select('#', GetBindingKey(button)) do - local key = select(k, GetBindingKey(button)) - SetOverrideBindingClick(self.bar, false, key, real_button) + + if not WoWRetail then + for i = 1, 10 do + local button, real_button = ("BONUSACTIONBUTTON%d"):format(i), ("BT4PetButton%d"):format(i) + for k=1, select('#', GetBindingKey(button)) do + local key = select(k, GetBindingKey(button)) + if self:IsKeybindWithModifier(key) then + SetOverrideBinding(self.bar, false, key, button) + else + SetOverrideBindingClick(self.bar, false, key, real_button) + end + end + end + else + for i = 1, 10 do + local button, real_button = ("BONUSACTIONBUTTON%d"):format(i), ("BT4PetButton%d"):format(i) + for k=1, select('#', GetBindingKey(button)) do + local key = select(k, GetBindingKey(button)) + SetOverrideBindingClick(self.bar, false, key, real_button) + end end end end @@ -151,3 +166,11 @@ function PetBar:ApplyConfig(config) self:ForAll("Update") self:ForAll("ApplyStyle", self.config.style) end + +function PetBarMod:IsKeybindWithModifier(key) + if key:find('^' .. "ALT") ~= nil then return true + elseif key:find('^' .. "CTRL") ~= nil then return true + elseif key:find('^' .. "SHIFT") ~= nil then return true + else return false + end +end \ No newline at end of file