Thread Tools Display Modes
02-20-24, 04:01 PM   #1
atshn
A Deviate Faerie Dragon
Join Date: Feb 2024
Posts: 19
How to change pet bar hotkey color?

I'm using this code to change the color of hotkeys for all my bars. Works fine for everything except the pet bar. Is "PetActionButton" not the correct name or am I completely off and the code doesn't work for the pet bar at all?

Code:
for i = 1, NUM_ACTIONBAR_BUTTONS do
   local hotkey = _G["PetActionButton"..i.."HotKey"]
   hotkey:SetFont("Fonts\\FRIZQT__.ttf", 12, "THICKOUTLINE")
end

local function CustomizeHotkey(self)
   local hotkey = _G[self:GetName().."HotKey"]
   hotkey:SetTextColor(1, 1, 1, 1)
end

hooksecurefunc("ActionButton_Update", CustomizeHotkey)
hooksecurefunc("ActionButton_OnUpdate", CustomizeHotkey)
  Reply With Quote
02-20-24, 07:22 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
PetActionBar has it's own set of Update routines. You probably need to hook into those to apply the changes to that bar.

https://github.com/Gethe/wow-ui-sour...ionBar.lua#L93
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
02-20-24, 10:03 PM   #3
atshn
A Deviate Faerie Dragon
Join Date: Feb 2024
Posts: 19
Originally Posted by Xrystal View Post
PetActionBar has it's own set of Update routines. You probably need to hook into those to apply the changes to that bar.

https://github.com/Gethe/wow-ui-sour...ionBar.lua#L93
I fear this one is over my head, but thank you for pointing me in the right direction.
  Reply With Quote
02-21-24, 12:09 AM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
I haven't tested these but, looking at the Blizzard Dragonflight code ( 10.2.5 ) these lines should work for the main action bar and pet action bar for retail wow.

Lua Code:
  1. for i=1, NUM_PET_ACTION_SLOTS, 1 do
  2.         local button = PetActionBar.actionButtons[i]);
  3.                 hooksecurefunc(button, "SetHotKeys",function()
  4.                     local hotkey = self.HotKey;
  5.                      -- do your hotkey additions here
  6.                 end)
  7.     end

Lua Code:
  1. for i, actionButton in pairs(ActionBar.actionButtons) do
  2.        hooksecurefunc(actionButton,"UpdateHotKeys",function()
  3.           local hotkey = self.HotKey;
  4.           -- do your hotkey additions here
  5.        end
  6.     end


If you are working on Classic versions of wow (1.14.4 and 3.4.3) then it looks like the following could be done instead. Again, untested.

Lua Code:
  1. for i=1, NUM_ACTIONBAR_SLOTS, 1 do
  2.         local button = _G["ActionButton" .. i]);
  3.                 hooksecurefunc("ActionButton_UpdateHotkeys",function(self)
  4.                     local hotkey = self.HotKey;
  5.                      -- do your hotkey additions here
  6.                 end)
  7.     end

Lua Code:
  1. for i=1, NUM_PET_ACTION_SLOTS, 1 do
  2.         local button = _G["PetActionButton" .. i]);
  3.                 hooksecurefunc("PetActionButton_SetHotKeys",function(self)
  4.                     local hotkey = _G[self:GetName().."HotKey"];
  5.                      -- do your hotkey additions here
  6.                 end)
  7.     end

Give those a go and let us know if they work as expected for you.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
02-21-24, 12:38 AM   #5
atshn
A Deviate Faerie Dragon
Join Date: Feb 2024
Posts: 19
Not working on Classic. Anything wrong with my hotkey additions?

Code:
for i=1, NUM_ACTIONBAR_SLOTS, 1 do
        local button = _G["ActionButton" .. i]);
                hooksecurefunc("ActionButton_UpdateHotkeys",function(self)
                    local hotkey = self.HotKey;
                     hotkey:SetFont("Fonts\\FRIZQT__.ttf", 12, "THICKOUTLINE")
                     hotkey:SetTextColor(1, 1, 1, 1)
                end)
    end

for i=1, NUM_PET_ACTION_SLOTS, 1 do
        local button = _G["PetActionButton" .. i]);
                hooksecurefunc("PetActionButton_SetHotKeys",function(self)
                    local hotkey = _G[self:GetName().."HotKey"];
                     hotkey:SetFont("Fonts\\FRIZQT__.ttf", 12, "THICKOUTLINE")
                     hotkey:SetTextColor(1, 1, 1, 1)
                end)
    end
  Reply With Quote
02-21-24, 04:22 AM   #6
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
Not that I can see. I'll play with it later and see if there's something else you have to do for it to work in Classic
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
02-21-24, 06:04 AM   #7
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
Okay, took a while, but managed to get it working on Wrath Classic 3.4.3 using the following code


Lua Code:
  1. local function UpdateHotKeys(self,buttonType)
  2.     local hotkey = self.HotKey;
  3.     hotkey:SetFont("Fonts\\FRIZQT__.ttf", 12, "THICKOUTLINE")
  4.     local binding = GetBindingText(GetBindingKey("ACTIONBUTTON"..self:GetID()), true);
  5.     hotkey:SetText("|cFF00FF00" .. binding or RANGE_INDICATOR .. "|r")
  6.     -- Green text on main action bars ( |cAARRGGBB text |r)
  7. end
  8.  
  9. for i=1, NUM_ACTIONBAR_BUTTONS, 1 do
  10.     local button = _G["ActionButton" .. i]
  11.     hooksecurefunc("ActionButton_UpdateHotkeys",UpdateHotKeys)
  12.     ActionButton_UpdateHotkeys(button)
  13. end
  14.  
  15.  
  16. local function SetHotKeys(self)
  17.     local hotkey = _G[self:GetName().."HotKey"];
  18.     hotkey:SetFont("Fonts\\FRIZQT__.ttf", 12, "THICKOUTLINE")
  19.     local binding = GetBindingText(GetBindingKey("BONUSACTIONBUTTON"..self:GetID()), true);
  20.     hotkey:SetText("|cFFFF0000" .. binding or RANGE_INDICATOR .. "|r")
  21.     -- Red text on pet action bars
  22. end
  23.  
  24. for i=1, NUM_PET_ACTION_SLOTS, 1 do
  25.     local button = _G["PetActionButton" .. i]
  26.     hooksecurefunc("PetActionButton_SetHotkeys",SetHotKeys)
  27.     PetActionButton_SetHotkeys(button)
  28. 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.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818

Last edited by Xrystal : 02-21-24 at 06:09 AM.
  Reply With Quote
02-21-24, 07:40 AM   #8
atshn
A Deviate Faerie Dragon
Join Date: Feb 2024
Posts: 19
Appreciate you taking the time to do that. Me and my old eyes thank you. Didn't have much time to test it in combat but did notice that the hotkey text acting as a range indicator on both pet and action bars no longer works.
  Reply With Quote
02-21-24, 08:28 AM   #9
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
Originally Posted by atshn View Post
Appreciate you taking the time to do that. Me and my old eyes thank you. Didn't have much time to test it in combat but did notice that the hotkey text acting as a range indicator on both pet and action bars no longer works.
oh, thought I had that covered with the RANGE_INDICATOR addition if there isn't a hot key set up

You could try using this in the hotkey functions and see if that works better

Lua Code:
  1. if ( binding == "" ) then
  2.    hotkey:SetText(RANGE_INDICATOR);
  3.    hotkey:Hide();
  4. else
  5.    hotkey:SetText("|cFF00FF00" .. binding .. "|r")
  6. end

or simplify it further to

Lua Code:
  1. if ( binding ~= "" ) then
  2.     hotkey:SetText("|cFF00FF00" .. binding .. "|r")
  3. end
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818

Last edited by Xrystal : 02-21-24 at 08:30 AM.
  Reply With Quote
02-21-24, 02:43 PM   #10
atshn
A Deviate Faerie Dragon
Join Date: Feb 2024
Posts: 19
Perfect. Thanks again, Xrystal!
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » How to change pet bar hotkey color?


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