WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   WoD Beta archived threads (https://www.wowinterface.com/forums/forumdisplay.php?f=151)
-   -   Keybindissue (https://www.wowinterface.com/forums/showthread.php?t=49731)

liquidbase 08-17-14 03:39 PM

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 :confused:

Lombra 08-17-14 03:50 PM

Seems fine. What is the problem exactly? Add some prints to see if the SetText call is happening, and with what value.

liquidbase 08-17-14 04:29 PM

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?

Lombra 08-17-14 06:04 PM

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.

p3lim 08-17-14 06:16 PM

Iterating the keys on UPDATE_BINDINGS and PLAYER_LOGIN works well.

liquidbase 08-18-14 02:58 AM

@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.

liquidbase 08-18-14 04:30 AM

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.


All times are GMT -6. The time now is 11:43 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI