Wikia

WoWWiki

API Button RegisterForClicks

Talk0
102,217pages on
this wiki
Revision as of 17:43, February 8, 2009 by Starlightblunder (Talk | contribs)

Widget API


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

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


Parameters

Arguments

Any number of the following strings:

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

Returns

nil


Example

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

Results

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

Details

  • 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 HAVE OnClick HANDLERS! If you want to trap mouse button events for other objects, use the OnMouseDown and OnMouseUp events.

Around Wikia's network

Random Wiki