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" [, ...]])


Any number of the following strings:



       self:RegisterForClicks("LeftButtonUp", "RightButtonDown");
       print("OnClick: "..arg1);
       print("OnMouseUp: "..arg1);
       print("OnMouseDown: "..arg1);


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


  • 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.
Community content is available under CC-BY-SA unless otherwise noted.