Run immediately before the button's OnClick handler with the same arguments. Useful for processing clicks on a button without interfering with handlers inherited from a secure template. For further details, see the example under OnClick.

Signature:

PreClick(self, "button", down)

Arguments:

  • self - Reference to the widget for which the script was run (button)

  • button - Name of the mouse button responsible for the click action (string)

    • Button4
    • Button5
    • LeftButton
    • MiddleButton
    • RightButton

  • down - True for a mouse button down action; false for button up or other actions (boolean)

Examples:




  if InCombatLockdown() then
    return
  end
  
  local class = select(2, UnitClass("target"))
  local spell
  if class == "WARRIOR" then
    spell = "Blessing of Kings"
  elseif class == "ROGUE" then
    spell = "Blessing of Might"
  else
    spell = "Blessing of Wisdom"
  end
  
  self:SetAttribute("spell", spell)