Quantcast Using GetBindingKey() on MultiActionBars - WoWInterface
Thread Tools Display Modes
06-18-19, 08:25 AM   #1
DashingSplash
A Murloc Raider
Join Date: Jun 2019
Posts: 7
Using GetBindingKey() on MultiActionBars

Hi,

I am currently having trouble with GetBindingKey() when trying to fetch the keybinds of the Multi Action Bars. Below is a sample code of my current AddOn.

Code:
local dashingDismount = CreateFrame("Frame")

function dashingBindings()
	local buttonName
	local actionType, id, _, actionName
	local key1, key2
	local ActionBars = {"Action","MultiBarBottomLeft","MultiBarBottomRight","MultiBarLeft","MultiBarRight"}
	
	for bar = 1, #ActionBars do
		for i = 1, 12 do
			buttonName = ActionBars[bar] .. "Button" .. i
						
			actionType, id, _ = GetActionInfo(_G[buttonName].action)
			actionName = GetSpellInfo(id)

			print(buttonName)

			key1, key2 = GetBindingKey(buttonName)

		    if key1 ~= nil then
				print(key1)
		    end
		    if key2 ~= nil then
				print(key2)
		    end
		end
	end
end

local function dashingInit(self, event, ...)
	dashingBindings()
end

dashingDismount:RegisterEvent("PLAYER_LOGIN")
dashingDismount:SetScript("OnEvent", dashingInit)
The code only manages to print(key1) for ActionButton1 to ActionButton12. MultiBarBottomLeftButton1 and beyond do not get to the print() at all. Am I missing something obvious?
  Reply With Quote
06-18-19, 07:43 PM   #2
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 424
Not sure why you assumed that the button names would correspond to the binding names,
but e.g. MultiBarBottomLeftButton1 is actually MULTIACTIONBAR1BUTTON1 in the binding manifest.
ActionButton1 just happens to correspond to ACTIONBUTTON1, but they are not the same.
__________________
  Reply With Quote
06-19-19, 12:33 PM   #3
DashingSplash
A Murloc Raider
Join Date: Jun 2019
Posts: 7
Originally Posted by MunkDev View Post
Not sure why you assumed that the button names would correspond to the binding names,
but e.g. MultiBarBottomLeftButton1 is actually MULTIACTIONBAR1BUTTON1 in the binding manifest.
ActionButton1 just happens to correspond to ACTIONBUTTON1, but they are not the same.
I made that assumption since the examples that I have seen uses them. However, I have tried and GetBindingKey() seems to be case sensitive: ActionButton1 works, while ACTIONBUTTON1 and any other variation does not.

After an hour of tinkering and trial-and-error I simply can't get MULTIACTIONBAR1BUTTON1 or MultiActionBar1Button1 to work.

With the following code I also only managed to get it to work with ActionButton1:

Code:
local function dashingBindings(low, high)
	for i=low,high do
		local Button
		local actionType, id, _
		local actionName
		local command, _, key1, key2 = GetBinding(i)
		
		if not command:find("HEADER_BLANK") then
			print(command)
		
			Button = string.gsub(_G["BINDING_NAME_" .. command], " ", "")
			
			print(Button)
			if _G[Button] ~= nil then
				actionType, id, _ = GetActionInfo(ActionButton_CalculateAction(_G[Button]))
				actionName = GetSpellInfo(id)
		
				if key1 ~= nil then
					print(key1)
				end
				if key2 ~= nil then
					print(key2)
				end
			end	
		end	
	end
end

local function dashingInit(self, event, ...)
	dashingBindings(31,42)
	dashingBindings(74,121)
end
The problem here is that Button = string.gsub(_G["BINDING_NAME_" .. command], " ", "") will produce the string BottomLeftActionButton1 while the variable "command" will contain the string MULTIACTIONBAR1BUTTON1. Not been able to utilize "command" with the GetBindingKey() function.

I seemingly can't get it to work at all, so if you have any suggestions where to go from here that would be great. If anyone else has any ideas, feel free to post them.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Using GetBindingKey() on MultiActionBars

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