WoW:UIHANDLER OnClick: Difference between revisions

no edit summary
(→‎Example: +XML handlers)
No edit summary
Line 9: Line 9:
==Example==
==Example==
  local taunts = {"I'm a button.", "Quit clicking me.", "That's enough.", "Stop it!", "I'm leaving!"};
  local taunts = {"I'm a button.", "Quit clicking me.", "That's enough.", "Stop it!", "I'm leaving!"};
  local widget = CreateFrame("Button", "TauntingButton", UIParent, "UIPanelButonTemplate");
  local widget = CreateFrame("Button", "TauntingButton", UIParent, "UIPanelButtonTemplate");
  widget:SetWidth(200); widget:SetHeight(24); widget:SetPoint("CENTER");
  widget:SetWidth(200); widget:SetHeight(24); widget:SetPoint("CENTER");
  widget:RegisterForClicks("AnyUp");
  widget:RegisterForClicks("AnyUp");
  widget:SetHandler("OnClick", function (self, button, down)
  widget:SetScript("OnClick", function (self, button, down)
   self:SetID((self:GetID() or 1) + 1);
   self:SetID((self:GetID() or 1) + 1);
   if taunts[self:GetID()] then
   if taunts[self:GetID()] then
Anonymous user