Thread Tools Display Modes
11-20-23, 09:40 AM   #1
Heybarbaruiva
A Murloc Raider
 
Heybarbaruiva's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2016
Posts: 9
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!

Last edited by Heybarbaruiva : 11-20-23 at 01:05 PM.
  Reply With Quote
11-20-23, 02:34 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
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.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
11-20-23, 03:45 PM   #3
Heybarbaruiva
A Murloc Raider
 
Heybarbaruiva's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2016
Posts: 9
Originally Posted by Fizzlemizz View Post
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.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Clearing target/running macro on Event


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off