Changing hotkey text
So, here's what I have:
And here's what I want: Notice the mousewheel hotkey text. Looks much prettier in the second image, right? So I've secure hooked ActionButton_Update and am running a series of if statements to check if the hotkey text equals, for example, "Mouse Wheel Down" and changing it to what I want. My problem is that as soon as I enter combat, the hotkey text switches back to it's original form. I don't want to disable the SetText function (ActionButton1HotKey.SetText = function() end) because then the text won't change if I change my keybinds. Wat do? |
I think you'll need to have it create a second list of names, which is truncated. I'm not sure the button style includes a specific truncation method.
-Crissa |
Hi Stako,
The easiest thing to do would probably be to hook the GetBindingText function: Lua Code:
I’m not sure if “Mouse Wheel Down” and “Mouse Wheel Up” are exactly what it’s showing since the text is cut off in your screenshot, so change those if they’re not right, and add anything else that you want to change. |
Bumping because GetBindingText is protected now. Can't figure out what to do.
Edit: Secure hook ActionButton_UpdateHotkeys and do something like this: Code:
local function styleHotKeys(self, actionButtonType) |
Taken from Tukui so you can see whats going on
Lua Code:
|
sorry to super necro, but i was looking to do exactly this just now and found the above code to be incomplete. replace is the local so you also need:
Code:
local replace = string.gsub |
So I copy pasted the above code and added
Code:
local replace = string.gsub Code:
local text = hotkey:GetText() help! :D |
The code posted does nothing by itself. As per stako's post, you need to run that function using a secure hook on the ActionButton_UpdateHotkeys function:
Lua Code:
This will cause your function to be attached to the end of the default UI's hotkey update function, so every time that runs, your function is run immediately afterward. The "secure" part means that your function doesn't interact with the default UI's function, so it doesn't break anything or cause taint. A few more technical observations: - You only need to upvalue string.gsub once, not every time the function runs, so I moved that local declaration outside of the function. - It's not necessary to wrap the search patterns in parentheses; those are only needed (or useful) if you only wish to match a subset of the given pattern. Since that's not the case here, they're not needed. - It's not necessary to look up RANGE_INDICATOR in the _G table explicitly; this is assumed, and specifying _G adds another global lookup for no reason. Just compare to RANGE_INDICATOR directly. I also changed this in the above code. |
How does this work in 7.1?
Sorry for the ancient threadomancy but this mechanism has been solid all the way through 7.0.3 so no one has had to ask any new questions.
Unfortunately it's broken in 7.1 my code: Code:
local hotkey = _G[button:GetName()..'HotKey'] Note: This mechanism is used by several actionbar modifying addons including Moncai Hotkeys and others which I've seen are all getting reports of being broken in 7.1 I've been looking at the FrameXML code for ActionButton but using the methods in there to resolve the text also does not yield the modifier text for me... Code:
local hotkey = _G[button:GetName()..'HotKey'] Confused as heck and scratching my head... Anyone have any insight? Many thanks in advance. joev |
Don't use hardcoded strings like "SPACE", "INSERT", "(s%-)", use global variables instead, e.g. SHIFT_KEY_TEXT, KEY_SPACE, KEY_INSERT, cuz different languages use different names for said keys :p
I do something like this and it works fine... Lua Code:
P.S. high lvl necromancy :p |
Quote:
I have tried your approach and it's still not yielding the expected results. My ABs are set up by LibActionButton which hasn't had a 7.1 update so I'll have a root around in the code of that because I suspect it's borked by something changed in 7.1 (though looking at the FrameXML/ActionButton code I'm still stumped as to why because it doesn't look manifestly different to 7.0.3) Thanks for the snippet though. I've used it :) Quote:
|
Can you post your entire, actual code please? If you're hooking ActionButton_UpdateHotkeys, you do not need to manually look up the hotkey for the button -- just look at and modify the text the original Blizzard function set on the button. hooksecurefunc means that the original function runs first, and then your function runs immediately afterward.
If you're not hooking ActionButton_UpdateHotkeys (for example, if you're trying to display a hotkey on a custom button) then your problem isn't related to this thread, and should be moved to a new thread. |
All times are GMT -6. The time now is 08:25 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI