Pre/post click question

if i have a pre or post click function can the preclick return something to tell the onlick to not bother? and can the postclick tell if the onclick handled it already?

pre-click - a normal right click of an item. if its marked as junk and has no sell price then delete it - and tell the onclick to not bother

postclick - a normal right click of an item. if the socketing frame is open and theres an open slot i want to pick up the item and slot it - but only if the item hasnt been handled by the onclick function (which in timerunning would merge 3 gems into a higher version)

My take:
The pre-click would be a no.

The post click would most likely be a no depending on wether it requires a hardware click to perform the action independant of the actual click it’s “post” clicking…

Out of combat it’s pretty easy. Rematch has a heal button that will not cast if no pets need healed:

function preClicks:HealButton(button)
    if isAnyPetInjured() then
        self:SetAttribute("type","spell") -- something needs healed, turn on the spell
    else
        self:SetAttribute("type",nil) -- all pets healed, turn off the spell
        self.tooltipNotice = L["All pets are at full health."]
        tooltips.HealButton(self) -- refresh tooltip immediately
    end
end

In combat it’s tricker since the state you’re deciding against must be defined before combat started. In that case you can set the attribute at PLAYER_REGEN_DISABLED and make no change in the PreClick while in combat.

There’s SecureHandlerWrapScript to do secure pre and post click scripts. These code snippets must obey secure rules so you’re not going to check unsecure stuff in combat but you can pass attributes to them before combat started.

2 Likes

it was more, if my preclick code processes the click can i tell the blizzard onclick to abort?

same for the postclick. if the blizzard onclick has processed the click then i dont want my code to run.

i thought there used to be a check function like modifiedclickhandled but i cant seem to find it anywhere anymore so it probably got deprecated

That is much more difficult and generally not possible by design.

As a rule, Blizzard doesn’t bother with SecureActionButtonTemplate and such. They can call UseContainerItem directly in combat which we can’t; and tampering with stuff in the path of a UseContainerItem will block the action the next time you’re in combat if not out of it.

The closest you can get to preventing a click is a floating intercepting frame under the mouse (and above the item).

i might switch to using a control-click then, at least that way theres never going to be any conflict with a normal-click use action, and the objects i want to mostly deal with dont have a dressup action