Quantcast
ActionBar: Shortcut for Flyouts and Vehicle Exit Buttons not working - WoWInterface
Thread Tools Display Modes
11-26-20, 11:32 PM   #1
Lybrial
A Flamescale Wyrmkin
AddOn Compiler - Click to view compilations
Join Date: Jan 2010
Posts: 118
ActionBar: Shortcut for Flyouts and Vehicle Exit Buttons not working

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:
  1. local customExitButton = {
  2.     func = function()
  3.         print("custom exit button func")
  4.  
  5.         if (UNITS:UnitExists("vehicle")) then
  6.             VehicleExit()
  7.         else
  8.             PetDismiss()
  9.         end
  10.     end,
  11.     texture = [[Interface\Icons\Spell_Shadow_SacrificialShield]],
  12.     tooltip = _G.LEAVE_VEHICLE,
  13. }
  14.  
  15. TABLES:ForEach(self.bars, function(_, bar)
  16.     for i = 1, 12 do
  17.         bar.buttons[i] = ACTION_BUTTON:CreateButton(i, STRINGS:Format(bar:GetName() .. "_Button_%d", i), bar, nil)
  18.         bar.buttons[i]:CreateTemplateBackdrop()
  19.         bar.buttons[i]:SetState(0, "action", i)
  20.  
  21.         for k = 1, 14 do
  22.             bar.buttons[i]:SetState(k, "action", ((k - 1) * 12) + i)
  23.         end
  24.  
  25.         if (i == 12) then
  26.             bar.buttons[i]:SetState(12, "custom", customExitButton)
  27.         end
  28.  
  29.         TABLES:Add(LybrialActionBars.buttons, bar.buttons[i])
  30.     end
  31.  
  32.     if (bar.db.conditions:find("[form]")) then
  33.         bar:SetAttribute("hasTempBar", true)
  34.     else
  35.         bar:SetAttribute("hasTempBar", false)
  36.     end
  37.  
  38.     bar:SetAttribute("_onstate-page", Player.OnStatePage)
  39. end)

2. Binding:

Lua Code:
  1. function KeyBind:OnBind(key)
  2.     KeyBind.hasChanges = true
  3.  
  4.     if (key == "ESCAPE") then
  5.         if (KeyBind.frame.button.bindings) then
  6.             for i = 1, #KeyBind.frame.button.bindings do
  7.                 SetBinding(KeyBind.frame.button.bindings[i])
  8.             end
  9.         end
  10.  
  11.         KeyBind:OnBindUpdate(KeyBind.frame.button, KeyBind.frame.spellMacro)
  12.  
  13.         return
  14.     end
  15.  
  16.     local isFlyOut = (KeyBind.frame.button.FlyoutArrow and KeyBind.frame.button.FlyoutArrow:IsShown())
  17.  
  18.     if ((key == "LSHIFT") or (key == "RSHIFT") or (key == "LCTRL") or (key == "RCTRL") or (key == "LALT") or (key == "RALT") or (key == "UNKNOWN")) then
  19.         return
  20.     end
  21.  
  22.     if ((key == "LeftButton") and isFlyOut) then
  23.         SecureActionButton_OnClick(KeyBind.frame.button)
  24.     end
  25.  
  26.     if (key == "MiddleButton") then
  27.         key = "BUTTON3"
  28.     end
  29.  
  30.     if (key:find("Button%d")) then
  31.         key = key:upper()
  32.     end
  33.  
  34.     local allowBinding = (not isFlyOut or (key ~= "LeftButton"))
  35.  
  36.     if (allowBinding and KeyBind.frame.button.bindString) then
  37.         local alt = IsAltKeyDown() and "ALT-" or ""
  38.         local ctrl = IsControlKeyDown() and "CTRL-" or ""
  39.         local shift = IsShiftKeyDown() and "SHIFT-" or ""
  40.  
  41.         SetBinding(alt .. ctrl .. shift .. key, KeyBind.frame.button.bindString)
  42.     end
  43.  
  44.     KeyBind:OnBindUpdate(KeyBind.frame.button, KeyBind.frame.spellMacro)
  45. end
  46.  
  47. function KeyBind:OnBindUpdate(button, spellMacro)
  48.     if ((not KeyBind.frame.active) or InCombatLockdown()) then
  49.         return
  50.     end
  51.  
  52.     KeyBind.frame.button = button
  53.     KeyBind.frame.spellMacro = spellMacro
  54.     KeyBind.frame.bindString = nil
  55.     KeyBind.frame:ClearAllPoints()
  56.     KeyBind.frame:SetAllPoints(button)
  57.     KeyBind.frame:Show()
  58.  
  59.     if (spellMacro == "FLYOUT") then
  60.         KeyBind.frame.button.name = KeyBind.frame.button.spellName
  61.         KeyBind.frame.button.bindString = spellMacro .. " " .. KeyBind.frame.button.name
  62.     elseif (spellMacro == "SPELL") then
  63.         KeyBind.frame.button.id = SpellBook_GetSpellBookSlot(KeyBind.frame.button)
  64.         KeyBind.frame.button.name = GetSpellBookItemName(KeyBind.frame.button.id, _G.SpellBookFrame.bookType)
  65.         KeyBind.frame.button.bindString = spellMacro .. " " .. KeyBind.frame.button.name
  66.     elseif (spellMacro == "MACRO") then
  67.         KeyBind.frame.button.id = KeyBind.frame.button:GetID()
  68.  
  69.         if ((MATH:Floor(.5 + select(2, _G.MacroFrameTab1Text:GetTextColor()) * 10) / 10) == .8) then
  70.             KeyBind.frame.button.id = KeyBind.frame.button.id + MAX_ACCOUNT_MACROS
  71.         end
  72.  
  73.         KeyBind.frame.button.name = GetMacroInfo(KeyBind.frame.button.id)
  74.         button.bindString = spellMacro .. " " .. KeyBind.frame.KeyBind.frame.button.name
  75.     elseif (spellMacro == "MICRO") then
  76.         KeyBind.frame.button.name = KeyBind.frame.button.tooltipText
  77.         KeyBind.frame.button.bindString = KeyBind.frame.button.commandName
  78.     elseif (spellMacro == "BAG") then
  79.         if (KeyBind.frame.button.itemID) then
  80.             KeyBind.frame.button.name = KeyBind.frame.button.name
  81.             KeyBind.frame.button.bindString = "ITEM item:" .. KeyBind.frame.button.itemID
  82.         end
  83.     else
  84.         KeyBind.frame.button.name = KeyBind.frame.button:GetName()
  85.  
  86.         if (not KeyBind.frame.button.name) then
  87.             return
  88.         end
  89.  
  90.         if (KeyBind.frame.button.keyBoundTarget) then
  91.             KeyBind.frame.button.bindString = KeyBind.frame.button.keyBoundTarget
  92.         elseif (KeyBind.frame.button.commandName) then -- pet and stance
  93.             KeyBind.frame.button.bindString = KeyBind.frame.button.commandName
  94.         elseif (KeyBind.frame.button.action) then
  95.             local action = MATH:ToNumber(KeyBind.frame.button.action)
  96.             local mod = (1 + ((action - 1) % 12))
  97.  
  98.             if (KeyBind.frame.button.name == "ExtraActionButton1") then
  99.                 KeyBind.frame.button.bindString = "EXTRAACTIONBUTTON1"
  100.             elseif ((KeyBind.frame.button.action < 25) or (KeyBind.frame.button.action > 72)) then
  101.                 KeyBind.frame.button.bindString = "ACTIONBUTTON" .. mod
  102.             elseif ((KeyBind.frame.button.action < 73) and (KeyBind.frame.button.action > 60)) then
  103.                 KeyBind.frame.button.bindString = "MULTIACTIONBAR1BUTTON" .. mod
  104.             elseif ((KeyBind.frame.button.action < 61) and (KeyBind.frame.button.action > 48)) then
  105.                 KeyBind.frame.button.bindString = "MULTIACTIONBAR2BUTTON" .. mod
  106.             elseif ((KeyBind.frame.button.action < 49) and (KeyBind.frame.button.action > 36)) then
  107.                 KeyBind.frame.button.bindString = "MULTIACTIONBAR4BUTTON" .. mod
  108.             elseif ((KeyBind.frame.button.action < 37) and (KeyBind.frame.button.action > 24)) then
  109.                 KeyBind.frame.button.bindString = "MULTIACTIONBAR3BUTTON" .. mod
  110.             end
  111.         end
  112.     end
  113.  
  114.     if (KeyBind.frame.button.bindString) then
  115.         KeyBind.frame.button.bindings = { GetBindingKey(KeyBind.frame.button.bindString) }
  116.     end
  117. end
  Reply With Quote
11-27-20, 12:23 PM   #2
Lybrial
A Flamescale Wyrmkin
AddOn Compiler - Click to view compilations
Join Date: Jan 2010
Posts: 118
SOLVED!

Lua Code:
  1. for _, bar in pairs(self.bars) do
  2.         if bar then
  3.             ClearOverrideBindings(bar)
  4.  
  5.             for _, button in ipairs(bar.buttons) do
  6.                 if button.keyBoundTarget then
  7.                     for k = 1, select('#', GetBindingKey(button.keyBoundTarget)) do
  8.                         local key = select(k, GetBindingKey(button.keyBoundTarget))
  9.                         if key and key ~= '' then
  10.                             SetOverrideBindingClick(bar, false, key, button:GetName())
  11.                         end
  12.                     end
  13.                 end
  14.             end
  15.         end
  16.     end
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » ActionBar: Shortcut for Flyouts and Vehicle Exit Buttons not working

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off