Quantcast Keybindissue - WoWInterface
 
Thread Tools Display Modes
08-17-14, 03:39 PM   #1
liquidbase
A Black Drake
 
liquidbase's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2010
Posts: 81
Keybindissue

Hey @ all!

I try to alter the keybind text with this small function:

Lua Code:
  1. local replace = string.gsub
  2. D.Keybind = function(self, actionButtonType)
  3.     local HotKey = _G[self:GetName().."HotKey"]
  4.     local Text = HotKey:GetText()
  5.  
  6.     Text = replace(Text, "(s%-)", "S")
  7.     Text = replace(Text, "(a%-)", "A")
  8.     Text = replace(Text, "(c%-)", "C")
  9.     Text = replace(Text, "(Mouse Button )", "M")
  10.     Text = replace(Text, KEY_BUTTON3, "M3")
  11.     Text = replace(Text, KEY_PAGEUP, "PU")
  12.     Text = replace(Text, KEY_PAGEDOWN, "PD")
  13.     Text = replace(Text, KEY_SPACE, "SpB")
  14.     Text = replace(Text, KEY_INSERT, "Ins")
  15.     Text = replace(Text, KEY_HOME, "Hm")
  16.     Text = replace(Text, KEY_DELETE, "Del")
  17.     Text = replace(Text, KEY_NUMPADDECIMAL, "Nu.")
  18.     Text = replace(Text, KEY_NUMPADDIVIDE, "Nu/")
  19.     Text = replace(Text, KEY_NUMPADMINUS, "Nu-")
  20.     Text = replace(Text, KEY_NUMPADMULTIPLY, "Nu*")
  21.     Text = replace(Text, KEY_NUMPADPLUS, "Nu+")
  22.     Text = replace(Text, KEY_NUMLOCK, "NuL")
  23.     Text = replace(Text, KEY_MOUSEWHEELDOWN, "MWD")
  24.     Text = replace(Text, KEY_MOUSEWHEELUP, "MWU")
  25.    
  26.     if HotKey:GetText() == _G["RANGE_INDICATOR"] then
  27.         HotKey:SetText("")
  28.     else
  29.         HotKey:SetText(Text)
  30.     end
  31. end
  32. hooksecurefunc("ActionButton_UpdateHotkeys", D.Keybind)

I know I had the correct update-function from the blizzardcode but the hotkeys won't change. I had already Mouse Button 4, a-Mouse Button 4 and so on. Is there a possibly an error I overlooked? A friend of mine used the same code and there it works fine. Currently I am a little perplexed
 
08-17-14, 03:50 PM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 544
Seems fine. What is the problem exactly? Add some prints to see if the SetText call is happening, and with what value.
__________________
Grab your sword and fight the Horde!
 
08-17-14, 04:29 PM   #3
liquidbase
A Black Drake
 
liquidbase's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2010
Posts: 81
That's the problem, it's fine but do not work. The print statements do not return anything, which I currently considers that, that the function is not executed.
It is the same function as I insets in DuffedUI v7 (as it works), only that I have replaced the values ​​to the global values​​ (e.g. "Home" to KEY_HOME).

@edit
It looks as if the function can be called only if I change a keybind, but not if I have a reload or Login performed. If the function "ActionButton_UpdateHotkeys" not trigger at PLAYER_ENTERING_WORLD?

Last edited by liquidbase : 08-17-14 at 04:34 PM. Reason: Additional informations
 
08-17-14, 06:04 PM   #4
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 544
Yes, it seems the text is only updated OnLoad (when the buttons are created, you won't be able to hook that) and when bindings change.

You could either call the hook for all buttons once in your addon, or hook some other function in addition, such as ActionButton_Update, which seems to fire on PLAYER_ENTERING_WORLD. That's also called on a lot of other occasions probably, so the former is probably the better solution.
__________________
Grab your sword and fight the Horde!
 
08-17-14, 06:16 PM   #5
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,617
Iterating the keys on UPDATE_BINDINGS and PLAYER_LOGIN works well.
 
08-18-14, 02:58 AM   #6
liquidbase
A Black Drake
 
liquidbase's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2010
Posts: 81
@Lombra
The old function from DuffedUI v7 won't work as welll because it is the same way I call the function.

@p3lim
That's right, but after /reloadui the function will not be executed. On live server I can reload the whole UI several times and the keybindtext will not change. The function also executes again only if I change a keybind.

Last edited by liquidbase : 08-18-14 at 03:19 AM.
 
08-18-14, 04:30 AM   #7
liquidbase
A Black Drake
 
liquidbase's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2010
Posts: 81
Have found a way to get the function even after a reload to trigger

Directly behind:
Lua Code:
  1. hooksecurefunc("ActionButton_OnEvent", function(self, event, ...)
  2.     if event == "PLAYER_ENTERING_WORLD"
  3.         then ActionButton_UpdateHotkeys(self, self.buttonType)
  4.     end
  5. end)
and it works.
 
 

WoWInterface » Site Forums » Archived Beta Forums » WoD Beta archived threads » Keybindissue

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