How to modify padding for MainMenuBar (Action Bar 1) in addon?

I have tried simply putting MainMenuBar.minButtonPadding = -2; MainMenuBar.buttonPadding = -1; into a local function, I have also tried using hooksecurefunc("a", function() end) and MainMenuBar:HookScript("OnEvent", function() end)

BUT no matter what I do, if I try to adjust things in the new UI Editor, and then “Share,” I will get an error like: tried to call the protected function 'CopyToClipboard()'. Which is really odd, because there is no copying going on. The addon I wrote is just brute forcing the removal of padding on my bars.

I will also get a similar error after about 30 minutes of questing, but it will be something along the lines of tried to call the protected function 'ClearTarget()'. Which, again is absurd because the addon in no way attempts to do anything beyond setting the padding for the action bars.

Are you referring to the spacing between buttons in the menu bar?

I don’t see a simple way to adjust that in Blizz’s code. You can do it with:

local MICRO_BUTTONS = {
	"CharacterMicroButton",
	"SpellbookMicroButton",
	"TalentMicroButton",
	"AchievementMicroButton",
	"QuestLogMicroButton",
	"GuildMicroButton",
	"LFDMicroButton",
	"EJMicroButton",
	"CollectionsMicroButton",
	"MainMenuMicroButton",
	"HelpMicroButton",
	"StoreMicroButton",
	}
for i = 2, #MICRO_BUTTONS do
  _G[MICRO_BUTTONS[i]]:SetPoint("BOTTOMLEFT", _G[MICRO_BUTTONS[i-1]], "BOTTOMRIGHT", 1, 0)
end

Haven’t tested; you may have to reorder that Enum. Change the 1, 0 as appropriate.

No, no-- “MainMenuBar” is the name of the primary action bar, or action bar 1 (yes, Blizzard’s choice of name here is confusing).

Using the in-game ui editor, you can only drop the action bar’s padding to a minimum of 2. My goal here is to manually set the padding lower than that limit.

1 Like

Oh I see. Changing MainMenuBar.buttonPadding will taint that field, when EditMode and other code reads it, that taints it too, leading to your protected function errors.

You’ll need to find the actual subframes and change their padding with SetPoint.

So, ActionButton1 through ActionButton12, and I use SetPoint… I see. Will have to give that a try when I wake up later.

There is no way to do the entire bar securely though? I thought that was the entire idea behind hooksecurefunc – That is to say, it is the safe way to hook into functions that execute protected functionality.

Tenchu (the OP) here! Thank you for your advice Doomsberg! I took your suggestion and made:

local ACTION_BARS = {
	"ActionButton",
	"MultiBarBottomLeftButton",
	"MultiBarBottomRightButton",
	}
for barNum = 1, #ACTION_BARS do
	local ButtonName = ACTION_BARS[barNum]
	for i = 2,12,1 do
		local ButtonsOntoBar = ButtonName .. i
		local PreviousButton = ButtonName .. i-1
		_G[ButtonsOntoBar]:SetPoint("BOTTOMLEFT", PreviousButton, "BOTTOMRIGHT", -1, 0)
	end
end

As a result, I am no longer getting errors!

1 question though: I tried a number of variations to the line of _G[MICRO_BUTTONS[i]]:SetPoint in the code you initially posted, but could not get SetPoint to work without the _G[ ] (it would return nil), despite print(MICRO_BUTTONS[i]) appearing to return the correct values on it’s own… Why is the _G[ ] needed here?

For your code:
ACTION_BARS[1] = “ActionButton”
ButtonName = “ActionButton”
i = 2
ButtonsOntoBar = “ActionButton1”
_G[ButtonsOntoBar] → _G[“ActionButton1”] → ActionButton1
It turns the String “ActionButton1” into the Global Variable named ActionButton1.

Idk why its not throwing an error for PreviousButton not being surrounded by _G though. Maybe SetPoint turns the string into a _G call internally.

1 Like

Ahhh! Ok, that makes sense.