Originally Posted by MunkDev
Awesome-code
|
Wow! Now that's some clean and good-looking code. Thank you for the help.
Was really surprised to see that
Lua Code:
local prefix = SecureButton_GetModifierPrefix()
local binding = GetBindingAction(prefix .. key)
was a thing. Although, I assume I'll get a better understanding of the API with some experience.
The only thing that had to be included in your code was to allow companion, item, and macro functionality. See modified function below. Any input on that?
Lua Code:
frame:EnableKeyboard(true)
frame:SetPropagateKeyboardInput(true)
frame:SetScript('OnKeyDown', function(self, key, ...)
if IsMounted() then
local prefix = SecureButton_GetModifierPrefix()
local binding = GetBindingAction(prefix .. key)
local button = actionButtons[binding]
if button then
local action = ActionButton_CalculateAction(button)
if HasAction(action) then
local actionType, spellID = GetActionInfo(action)
if (actionType == 'spell' or actionType == 'item' or actionType == 'companion') and not protectedSkills[spellID] then
Dismount()
elseif actionType == "macro" then
spellID, _ = GetMacroSpell(spellID)
if spellID ~= nil and not protectedSkills[spellID] then
Dismount()
end
end
end
return
end
button = stanceButtons[binding]
if button and not button:GetChecked() then
Dismount()
end
end
end)
The only thing I am unsure about is how
Lua Code:
button = stanceButtons[binding]
if button and not button:GetChecked() then
Dismount()
end
works. When and how is the button state set to checked?
frame:EnableKeyboard(true) seems moot. Can set it to false (or even remove it completely) and the addon will still work. In my first version I had to set the frame to inherit from UIParent, and then show the frame for EnableKeyboard to actually work. Safe to remove it, or does it actually have some hidden function?