Okay, took a while, but managed to get it working on Wrath Classic 3.4.3 using the following code
Lua Code:
local function UpdateHotKeys(self,buttonType)
local hotkey = self.HotKey;
hotkey:SetFont("Fonts\\FRIZQT__.ttf", 12, "THICKOUTLINE")
local binding = GetBindingText(GetBindingKey("ACTIONBUTTON"..self:GetID()), true);
hotkey:SetText("|cFF00FF00" .. binding or RANGE_INDICATOR .. "|r")
-- Green text on main action bars ( |cAARRGGBB text |r)
end
for i=1, NUM_ACTIONBAR_BUTTONS, 1 do
local button = _G["ActionButton" .. i]
hooksecurefunc("ActionButton_UpdateHotkeys",UpdateHotKeys)
ActionButton_UpdateHotkeys(button)
end
local function SetHotKeys(self)
local hotkey = _G[self:GetName().."HotKey"];
hotkey:SetFont("Fonts\\FRIZQT__.ttf", 12, "THICKOUTLINE")
local binding = GetBindingText(GetBindingKey("BONUSACTIONBUTTON"..self:GetID()), true);
hotkey:SetText("|cFFFF0000" .. binding or RANGE_INDICATOR .. "|r")
-- Red text on pet action bars
end
for i=1, NUM_PET_ACTION_SLOTS, 1 do
local button = _G["PetActionButton" .. i]
hooksecurefunc("PetActionButton_SetHotkeys",SetHotKeys)
PetActionButton_SetHotkeys(button)
end
The call after the hook line triggers it straight away, otherwise it won't trigger until you change the hot key via the options. Not sure whether there will be in combat/secure issues but hopefully being done immediately on addon load rather than via event watching means it won't be a problem.
SetTextColor doesn't seem to make a difference at all regardless of where you put it in the code. But, inserting the |c and |r start and end color formatting code sequences seems to work as expected.