WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Clearing target/running macro on Event (https://www.wowinterface.com/forums/showthread.php?t=59711)

Heybarbaruiva 11-20-23 09:40 AM

Clearing target/running macro on Event
 
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!

Fizzlemizz 11-20-23 02:34 PM

Secure actions require a hardware event ie. a physical click of the button via mouse click or keybind. Trying to do it programatically won't work.

Heybarbaruiva 11-20-23 03:45 PM

Quote:

Originally Posted by Fizzlemizz (Post 342925)
Secure actions require a hardware event ie. a physical click of the button via mouse click or keybind. Trying to do it programatically won't work.

I see. That's unfortunate. Appreciate the help.


All times are GMT -6. The time now is 12:28 PM.

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