Open main menu
Home
Random
Log in
Settings
About AddOn Studio
Disclaimers
AddOn Studio
Search
Editing
WoW:UIHANDLER OnClick
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{widgethandler}} The '''OnClick''' handler is called when a UI widget that supports clicking (i.e. is derived from a Button) is clicked. Region derivatives like Frame only implement OnMouseDown / OnMouseUp handlers. == Arguments == ;self : widget being clicked ;button : [mouse] button used to click the widget. Due to widget:Click(button, down), button argument may be anything, although the following five values are common for normal mouse clicks: "LeftButton", "RightButton", "MiddleButton", "Button4", "Button5". ;down : Boolean - 1 (true) if the trigger button is currently being held down, nil (false) otherwise. ==Example== local taunts = {"I'm a button.", "Quit clicking me.", "That's enough.", "Stop it!", "I'm leaving!"}; local widget = CreateFrame("Button", "TauntingButton", UIParent, "UIPanelButtonTemplate"); widget:SetWidth(200); widget:SetHeight(24); widget:SetPoint("CENTER"); widget:RegisterForClicks("AnyUp"); widget:SetScript("OnClick", function (self, button, down) self:SetID((self:GetID() or 1) + 1); if taunts[self:GetID()] then self:SetText(taunts[self:GetID()]); else self:Hide(); end end); The named arguments are also available in XML handlers: <Button name="foo" ...> ... <Scripts> ... <OnClick>self:SetText("You clicked with " .. button);</OnClick> </Scripts> </Button>
Summary:
Please note that all contributions to AddOn Studio are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
AddOn Studio Wiki:Copyrights
for details).
Submissions must be written by you, or copied from a public domain or similar free resource (see
AddOn Studio Wiki:Copyrights
for details).
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Apinav
(
edit
)
Template:Editlink
(
edit
)
Template:Tocright
(
edit
)
Template:Widget
(
edit
)
Template:Widgethandler
(
edit
)