Thread Tools Display Modes
10-26-22, 04:23 PM   #1
DewDrop87
A Defias Bandit
Join Date: Oct 2022
Posts: 2
How to edit the hotkey text of PetActionButton

I've been updating the hotkey text of my action bars to rename things like s-1 to S1 and I can't seem to figure out how to do the same for the petbar which defaults to c-1, c-2 etc. I don't get any errors but nothing seems to happen. I've also tried to print out the text value of these hotkeys and I don't get 'c-1' etc which is weird.

The code being used for this is the following

Code:
local replace = string.gsub
 
local function UpdateHotkey(self, actionButtonType)
	local hotkey = _G[self:GetName() .. "HotKey"]
	local text = hotkey:GetText()
	
	text = replace(text, "s%-", "S")
	text = replace(text, "a%-", "A")
	text = replace(text, "c%-", "C")
	text = replace(text, "Mouse Button ", "M")
	
	if hotkey:GetText() == RANGE_INDICATOR then
		hotkey:SetText("")
	else
		hotkey:SetText(text)
	end
end

for i = 1, 10 do
    hooksecurefunc(_G["PetActionButton"..i], "UpdateHotkeys", UpdateHotkey)
end
Any ideas? Do the pet action buttons function differently to the other action buttons?
  Reply With Quote
10-27-22, 04:12 AM   #2
glupikreten
A Theradrim Guardian
Join Date: Apr 2009
Posts: 60
maybe

hooksecurefunc(
'PetActionButton_SetHotkeys',
function(self)
...
end
)
  Reply With Quote
10-27-22, 02:06 PM   #3
DewDrop87
A Defias Bandit
Join Date: Oct 2022
Posts: 2
Originally Posted by glupikreten View Post
maybe

hooksecurefunc(
'PetActionButton_SetHotkeys',
function(self)
...
end
)
Ah perfect, swapping to SetHotkeys worked

Code:
for i = 1, NUM_PET_ACTION_SLOTS do
    hooksecurefunc(_G["PetActionButton"..i], "SetHotkeys", UpdateHotkey)
end
  Reply With Quote
10-28-22, 04:21 AM   #4
glupikreten
A Theradrim Guardian
Join Date: Apr 2009
Posts: 60
Im not very good at lua language so i dont know if there is a difference but you do 12 hooksecurefunc binds when you could do only one...

this is what i have (not my code.. its from nMainbar.. i just modified it little):

Lua Code:
  1. local UpdateHotkeys = function(input)
  2.     local hotkey = _G[input:GetName() .. 'HotKey']
  3.     local text = hotkey:GetText()
  4.  
  5.     if (text and text ~= RANGE_INDICATOR) then
  6.         text = gsub(text, '(s%-)', 'S-')
  7.         text = gsub(text, '(a%-)', 'A-')
  8.         text = gsub(text, '(c%-)', 'C-')
  9.         text = gsub(text, '(st%-)', 'C-') -- german control 'Steuerung'
  10.  
  11.         for i = 1, 30 do
  12.             text = gsub(text, _G['KEY_BUTTON' .. i], 'M' .. i)
  13.         end
  14.  
  15.         for i = 1, 9 do
  16.             text = gsub(text, _G['KEY_NUMPAD' .. i], 'NU' .. i)
  17.         end
  18.  
  19.         text = gsub(text, KEY_MOUSEWHEELUP, 'MU')
  20.         text = gsub(text, KEY_MOUSEWHEELDOWN, 'MD')
  21.         text = gsub(text, KEY_NUMLOCK, 'NL')
  22.         text = gsub(text, KEY_PAGEUP, 'PU')
  23.         text = gsub(text, KEY_PAGEDOWN, 'PD')
  24.         text = gsub(text, KEY_SPACE, '_')
  25.         text = gsub(text, KEY_INSERT, 'INS')
  26.         text = gsub(text, KEY_HOME, 'HM')
  27.         text = gsub(text, KEY_DELETE, 'DEL')
  28.  
  29.         hotkey:SetText(text)
  30.     else
  31.         -- hotkey:SetPoint('TOPLEFT', button, 'TOPLEFT', 1, -2)
  32.         -- hotkey:Hide()
  33.         hotkey:SetText('')
  34.     end
  35. end
  36.  
  37. hooksecurefunc(
  38.     'ActionButton_UpdateHotkeys',
  39.     function(self)
  40.         UpdateHotkeys(self)
  41.     end
  42. )
  43. hooksecurefunc(
  44.     'PetActionButton_SetHotkeys',
  45.     function(self)
  46.         UpdateHotkeys(self)
  47.     end
  48. )
  Reply With Quote
10-28-22, 10:56 AM   #5
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,918
They've recently changed the functions.

'PetActionButton_SetHotkeys' is now PetActionButton1:SetHotKeys() .. PetActionButton2:SetHotKeys() etc. Each button has its own function so you have to hook into each one.
__________________
  Reply With Quote
10-31-22, 11:39 AM   #6
glupikreten
A Theradrim Guardian
Join Date: Apr 2009
Posts: 60
Is that for DF? Because i play WOTLK... dunno anything about v.10

And i didn't even bother to think about other versions of wow
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » How to edit the hotkey text of PetActionButton

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