Action bar hotkey text

I’m trying to get out of the custom UI scene and start using mostly default UI. I do have a question about the hotkey text on your action bar. Is there any way of shortening down the text?

Right now it just tries to show “Num key 1” which leaves all the buttons looking like “Nu…” instead of just showing N1.

You can use the following Lua code to create a lightweight addon that just replaces the hotkey text:

function updateHotkeyText()
	local ActionBars = {'Action','MultiBarBottomLeft','MultiBarBottomRight','MultiBarRight','MultiBarLeft'}
	--iterate the different actionbars
	for _, barName in pairs(ActionBars) do
		--iterate the individual actionbar buttons (12 each)
		for i = 1, 12 do
			local button = _G[barName .. 'Button' .. i]
			local hotkey = button['HotKey']
			local text = hotkey:GetText()
			if text ~= nil then
				---------------------
				--Modifiers
				---------------------
				--shift
				text = string.gsub(text, "(s%-)", "S")
				--alt
				text = string.gsub(text, "(a%-)", "A")
				--ctrl
				text = string.gsub(text, "(c%-)", "C")
				---------------------
				--Mouse-Buttons
				---------------------
				--Left Mouse Button
				text = string.gsub(text, KEY_BUTTON1, "LM")
				--Right Mouse Button
				text = string.gsub(text, KEY_BUTTON2, "RM")
				--Middle Mouse Button
				text = string.gsub(text, KEY_BUTTON3, "MM")
				--Mouse Extra Button 1
				text = string.gsub(text, KEY_BUTTON4, "M4")
				--Mouse Extra Button 2
				text = string.gsub(text, KEY_BUTTON5, "M5")
				text = string.gsub(text, KEY_MOUSEWHEELDOWN, "MWD")
				text = string.gsub(text, KEY_MOUSEWHEELUP, "MWU")
				---------------------
				--Special Keys
				---------------------
				text = string.gsub(text, KEY_PAGEUP, "PU")
				text = string.gsub(text, KEY_PAGEDOWN, "PD")
				text = string.gsub(text, KEY_SPACE, "SpB")
				text = string.gsub(text, KEY_INSERT, "Ins")
				text = string.gsub(text, KEY_HOME, "Hm")
				text = string.gsub(text, KEY_DELETE, "Del")
				---------------------
				--Numpad
				---------------------
				text = string.gsub(text, "Num Pad %.", "N.")
				text = string.gsub(text, "Num Pad %/", "N/")
				text = string.gsub(text, "Num Pad %-", "N-")
				text = string.gsub(text, "Num Pad %*", "N*")
				text = string.gsub(text, "Num Pad %+", "N+")
				text = string.gsub(text, KEY_NUMLOCK, "NL")
				text = string.gsub(text, KEY_NUMPAD0, "N0")
				text = string.gsub(text, KEY_NUMPAD1, "N1")
				text = string.gsub(text, KEY_NUMPAD2, "N2")
				text = string.gsub(text, KEY_NUMPAD3, "N3")
				text = string.gsub(text, KEY_NUMPAD4, "N4")
				text = string.gsub(text, KEY_NUMPAD5, "N5")
				text = string.gsub(text, KEY_NUMPAD6, "N6")
				text = string.gsub(text, KEY_NUMPAD7, "N7")
				text = string.gsub(text, KEY_NUMPAD8, "N8")
				text = string.gsub(text, KEY_NUMPAD9, "N9")
				---------------------
				 
				if hotkey:GetText() == RANGE_INDICATOR then
					hotkey:SetText('')
				else
					hotkey:SetText(text)
				end
			end
		end
	end
end

local function OnEvent(self, event, isInitialLogin, isReloadingUi)
	updateHotkeyText()
end

local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_LOGIN")
f:RegisterEvent("UPDATE_BINDINGS")
f:SetScript("OnEvent", OnEvent)

Find the Hotkey for which you want to change the hotkey text and replace the Display Text with whatever you like.

Lines with hotkeys you don’t want to change, can be safely removed.


Once you’re done mark all the code (Ctrl+A) and copy it (Ctrl+C).

Now head over to https://addon.bool.no/ (a site to convert Lua code into a lightweight addon)

Paste the code (Ctrl+V) and give your AddOn a fitting name.

Press Download and save and install the Addon like you would with any other Addon from Curse.

Preview



If you want to make changes to the hotkey text later, you can just edit the core.lua file in the Addons main directory (World of Warcraft\_retail_\Interface\AddOns\<YourAddonName>\core.lua).

If you have any questions regarding the code, feel free to let me know.

11 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.