Fandom

WoWWiki

API Button RegisterForClicks

104,632pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Widget API ← Button < RegisterForClicks

Control which mouse button up/down events get passed to the <OnClick> event handler. See also XML registerForClicks.

  button:RegisterForClicks("clicktype1" [, "clicktype2" [, ...]])

Arguments Edit

Any number of the following strings:

"LeftButtonUp"
"RightButtonUp"
"MiddleButtonUp"
"Button4Up"
"Button5Up"
"LeftButtonDown"
"RightButtonDown"
"MiddleButtonDown"
"Button4Down"
"Button5Down"
"AnyUp"
"AnyDown"

Example Edit

 <Button>
   <Scripts>
     <OnLoad>
       self:RegisterForClicks("LeftButtonUp", "RightButtonDown");
     </OnLoad>
     <OnClick>
       print("OnClick: "..arg1);
     </OnClick>
     <OnMouseUp>
       print("OnMouseUp: "..arg1);
     </OnMouseUp>
     <OnMouseDown>
       print("OnMouseDown: "..arg1);
     </OnMouseDown>
       

Results Edit

Clicking the Left, Right and Middle buttons in turn will produce:

 OnMouseDown: LeftButton

 OnMouseUp: LeftButton
 OnClick: LeftButton

 OnMouseDown: RightButton
 OnClick: RightButton

 OnMouseUp: RightButton

 OnMouseDown: MiddleButton

 OnMouseUp: MiddleButton

DetailsEdit

  • Buttons default to having "LeftButtonUp" registered for clicks.
  • Registering for () means <OnClick> will never trigger.
  • Registering for invalid event names will not cause errors; invalid names are silently ignored.
  • The <OnMouseDown> and <OnMouseUp> handlers will always receieve all mouse up/down events.
  • ONLY BUTTONS (and widgets that inherit from Button) HAVE OnClick HANDLERS! If you want to trap mouse button events for other objects, use the OnMouseDown and OnMouseUp events.

Also on Fandom

Random Wiki