Hi,
Im using
LibActionButton
to create action buttons for action bars and it works really nice!
- Tooltips are working
- Click Actions are working
- HotKey Bindings are working
- HotKey Actions are working
There are only two exceptions:
- HotKey Action on Flyout Buttons is not working (But binding them is!)
- Hotkey Action on Vehicle Exit Button is not working (But binding it is!)
Clicking Flyout Buttons or Vehicle Exit Buttons is working and the tooltips are also showing correctly.
Really the only thing which is not working is opening the flyout by pressing the assigned hotkey
or leaving a vehicle by using the assigned hotkey and I cant find out why it is not working.
Thx and have a great time in shadowlands!
Some Code Snippets:
1. Creating buttons:
Lua Code:
local customExitButton = {
func = function()
print("custom exit button func")
if (UNITS:UnitExists("vehicle")) then
VehicleExit()
else
PetDismiss()
end
end,
texture = [[Interface\Icons\Spell_Shadow_SacrificialShield]],
tooltip = _G.LEAVE_VEHICLE,
}
TABLES:ForEach(self.bars, function(_, bar)
for i = 1, 12 do
bar.buttons[i] = ACTION_BUTTON:CreateButton(i, STRINGS:Format(bar:GetName() .. "_Button_%d", i), bar, nil)
bar.buttons[i]:CreateTemplateBackdrop()
bar.buttons[i]:SetState(0, "action", i)
for k = 1, 14 do
bar.buttons[i]:SetState(k, "action", ((k - 1) * 12) + i)
end
if (i == 12) then
bar.buttons[i]:SetState(12, "custom", customExitButton)
end
TABLES:Add(LybrialActionBars.buttons, bar.buttons[i])
end
if (bar.db.conditions:find("[form]")) then
bar:SetAttribute("hasTempBar", true)
else
bar:SetAttribute("hasTempBar", false)
end
bar:SetAttribute("_onstate-page", Player.OnStatePage)
end)
2. Binding:
Lua Code:
function KeyBind:OnBind(key)
KeyBind.hasChanges = true
if (key == "ESCAPE") then
if (KeyBind.frame.button.bindings) then
for i = 1, #KeyBind.frame.button.bindings do
SetBinding(KeyBind.frame.button.bindings[i])
end
end
KeyBind:OnBindUpdate(KeyBind.frame.button, KeyBind.frame.spellMacro)
return
end
local isFlyOut = (KeyBind.frame.button.FlyoutArrow and KeyBind.frame.button.FlyoutArrow:IsShown())
if ((key == "LSHIFT") or (key == "RSHIFT") or (key == "LCTRL") or (key == "RCTRL") or (key == "LALT") or (key == "RALT") or (key == "UNKNOWN")) then
return
end
if ((key == "LeftButton") and isFlyOut) then
SecureActionButton_OnClick(KeyBind.frame.button)
end
if (key == "MiddleButton") then
key = "BUTTON3"
end
if (key:find("Button%d")) then
key = key:upper()
end
local allowBinding = (not isFlyOut or (key ~= "LeftButton"))
if (allowBinding and KeyBind.frame.button.bindString) then
local alt = IsAltKeyDown() and "ALT-" or ""
local ctrl = IsControlKeyDown() and "CTRL-" or ""
local shift = IsShiftKeyDown() and "SHIFT-" or ""
SetBinding(alt .. ctrl .. shift .. key, KeyBind.frame.button.bindString)
end
KeyBind:OnBindUpdate(KeyBind.frame.button, KeyBind.frame.spellMacro)
end
function KeyBind:OnBindUpdate(button, spellMacro)
if ((not KeyBind.frame.active) or InCombatLockdown()) then
return
end
KeyBind.frame.button = button
KeyBind.frame.spellMacro = spellMacro
KeyBind.frame.bindString = nil
KeyBind.frame:ClearAllPoints()
KeyBind.frame:SetAllPoints(button)
KeyBind.frame:Show()
if (spellMacro == "FLYOUT") then
KeyBind.frame.button.name = KeyBind.frame.button.spellName
KeyBind.frame.button.bindString = spellMacro .. " " .. KeyBind.frame.button.name
elseif (spellMacro == "SPELL") then
KeyBind.frame.button.id = SpellBook_GetSpellBookSlot(KeyBind.frame.button)
KeyBind.frame.button.name = GetSpellBookItemName(KeyBind.frame.button.id, _G.SpellBookFrame.bookType)
KeyBind.frame.button.bindString = spellMacro .. " " .. KeyBind.frame.button.name
elseif (spellMacro == "MACRO") then
KeyBind.frame.button.id = KeyBind.frame.button:GetID()
if ((MATH:Floor(.5 + select(2, _G.MacroFrameTab1Text:GetTextColor()) * 10) / 10) == .8) then
KeyBind.frame.button.id = KeyBind.frame.button.id + MAX_ACCOUNT_MACROS
end
KeyBind.frame.button.name = GetMacroInfo(KeyBind.frame.button.id)
button.bindString = spellMacro .. " " .. KeyBind.frame.KeyBind.frame.button.name
elseif (spellMacro == "MICRO") then
KeyBind.frame.button.name = KeyBind.frame.button.tooltipText
KeyBind.frame.button.bindString = KeyBind.frame.button.commandName
elseif (spellMacro == "BAG") then
if (KeyBind.frame.button.itemID) then
KeyBind.frame.button.name = KeyBind.frame.button.name
KeyBind.frame.button.bindString = "ITEM item:" .. KeyBind.frame.button.itemID
end
else
KeyBind.frame.button.name = KeyBind.frame.button:GetName()
if (not KeyBind.frame.button.name) then
return
end
if (KeyBind.frame.button.keyBoundTarget) then
KeyBind.frame.button.bindString = KeyBind.frame.button.keyBoundTarget
elseif (KeyBind.frame.button.commandName) then -- pet and stance
KeyBind.frame.button.bindString = KeyBind.frame.button.commandName
elseif (KeyBind.frame.button.action) then
local action = MATH:ToNumber(KeyBind.frame.button.action)
local mod = (1 + ((action - 1) % 12))
if (KeyBind.frame.button.name == "ExtraActionButton1") then
KeyBind.frame.button.bindString = "EXTRAACTIONBUTTON1"
elseif ((KeyBind.frame.button.action < 25) or (KeyBind.frame.button.action > 72)) then
KeyBind.frame.button.bindString = "ACTIONBUTTON" .. mod
elseif ((KeyBind.frame.button.action < 73) and (KeyBind.frame.button.action > 60)) then
KeyBind.frame.button.bindString = "MULTIACTIONBAR1BUTTON" .. mod
elseif ((KeyBind.frame.button.action < 61) and (KeyBind.frame.button.action > 48)) then
KeyBind.frame.button.bindString = "MULTIACTIONBAR2BUTTON" .. mod
elseif ((KeyBind.frame.button.action < 49) and (KeyBind.frame.button.action > 36)) then
KeyBind.frame.button.bindString = "MULTIACTIONBAR4BUTTON" .. mod
elseif ((KeyBind.frame.button.action < 37) and (KeyBind.frame.button.action > 24)) then
KeyBind.frame.button.bindString = "MULTIACTIONBAR3BUTTON" .. mod
end
end
end
if (KeyBind.frame.button.bindString) then
KeyBind.frame.button.bindings = { GetBindingKey(KeyBind.frame.button.bindString) }
end
end