Wikia

WoWWiki

Changes: API Button RegisterForClicks

Edit

Back to page

(Example: self!)
(formatting changes; avoid this)
 
Line 1: Line 1:
 
{{widgetmethod}}
 
{{widgetmethod}}
 
 
Control which mouse button up/down events get passed to the <OnClick> event handler.
 
Control which mouse button up/down events get passed to the <OnClick> event handler.
  +
button:RegisterForClicks("clicktype1" [, "clicktype2" [, ...]])
   
this:RegisterForClicks("clicktype1" [, "clicktype2" [, ...]])
+
== Arguments ==
 
 
== Parameters ==
 
 
=== Arguments ===
 
 
Any number of the following strings:
 
Any number of the following strings:
 
: "LeftButtonUp"
 
: "LeftButtonUp"
Line 17: Line 17:
 
: "AnyUp"
 
: "AnyUp"
 
: "AnyDown"
 
: "AnyDown"
 
=== Returns ===
 
 
: nil
 
 
   
 
== Example ==
 
== Example ==
Line 30: Line 25:
 
</OnLoad>
 
</OnLoad>
 
<OnClick>
 
<OnClick>
DEFAULT_CHAT_FRAME:AddMessage("OnClick: "..arg1);
+
print("OnClick: "..arg1);
 
</OnClick>
 
</OnClick>
 
<OnMouseUp>
 
<OnMouseUp>
DEFAULT_CHAT_FRAME:AddMessage("OnMouseUp: "..arg1);
+
print("OnMouseUp: "..arg1);
 
</OnMouseUp>
 
</OnMouseUp>
 
<OnMouseDown>
 
<OnMouseDown>
DEFAULT_CHAT_FRAME:AddMessage("OnMouseDown: "..arg1);
+
print("OnMouseDown: "..arg1);
 
</OnMouseDown>
 
</OnMouseDown>
 
 
Line 58: Line 53:
   
 
==Details==
 
==Details==
 
 
* Buttons default to having "LeftButtonUp" registered for clicks.
 
* Buttons default to having "LeftButtonUp" registered for clicks.
 
 
* Registering for () means <OnClick> will never trigger.
 
* Registering for () means <OnClick> will never trigger.
 
 
* Registering for invalid event names will not cause errors; invalid names are silently ignored.
 
* 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.
 
* 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.
* '''ONLY BUTTONS HAVE OnClick HANDLERS!''' If you want to trap mouse button events for other objects, use the OnMouseDown and OnMouseUp events.
 

Latest revision as of 22:53, March 6, 2009

Widget API

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

  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.

Around Wikia's network

Random Wiki