Hey folks, I'm trying to clear the target on the
"ACTIONBAR_UPDATE_STATE" event, but no luck.
This is what the macro looks like in-game:
Code:
MYMACRO
/cleartarget [exists]
And this is the portion of my addon dealing with this functionality:
Code:
local ClearTargetBtn = _G.CreateFrame("Button", "ClearTargetBtn", _G.UIParent, "SecureActionButtonTemplate")
ClearTargetBtn:SetAttribute("type", "macro")
ClearTargetBtn:SetAttribute("macrotext", "/run MYMACRO") -- doesn't work
-- ClearTargetBtn:SetAttribute("macrotext", "/cleartarget") -- doesn't work either
local function ClearTargetOnEvent()
local isReticleTargetingActive = MYADDON.DB.global.reticleTargeting
if not isReticleTargetingActive then return end
ClearTargetBtn:Click()
print("clearing target") -- prints in chat
end
ClearTargetBtn:RegisterEvent("ACTIONBAR_UPDATE_STATE")
ClearTargetBtn:SetScript("OnEvent",ClearTargetOnEvent)
The
ClearTargetOnEvent() function is being fired when the event happens and I get the
"cleared target" print in chat, but the macro doesn't seem to be running.
Any ideas on what to do here to achieve the expected result, which is clearing the target so the player doesn't have a target selected anymore?
Appreciate you all!