Changeset 750

Show
Ignore:
Timestamp:
04/24/06 23:50:04 (2 years ago)
Author:
beau@hartshornesoftware.com
Message:

Signal doc updates

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mochikit/trunk/doc/html/MochiKit/Signal.html

    r742 r750  
    7373<p>This module takes care of all the hard work—figuring out which event 
    7474model to use, trying to retrieve the event object, and handling your own 
    75 internal events, as well as cleanup when the page is unloaded to handle IE's 
     75internal events, as well as cleanup when the page is unloaded to clean up IE's 
    7676nasty memory leakage.</p> 
    77 <p>This event system is largely based on Qt's signal/slot system. You should read 
    78 more on how that is handled and also how it is used in model/view programming 
    79 at: <a class="reference" href="http://doc.trolltech.com/">http://doc.trolltech.com/</a></p> 
     77<p>This event system is largely based on Qt's signal/slot system. Read more on 
     78how that is handled and also how it is used in model/view programming at: 
     79<a class="reference" href="http://doc.trolltech.com/">http://doc.trolltech.com/</a></p> 
    8080</div> 
    8181<div class="section"> 
     
    9090<div class="section"> 
    9191<h2><a id="using-signal-for-dom-events" name="using-signal-for-dom-events">Using Signal for DOM Events</a></h2> 
    92 <p>When using MochiKit.Signal, you should not directly use the browser's native 
    93 event handling for the same events. That means, no <tt class="docutils literal"><span class="pre">onclick=&quot;blah&quot;</span></tt>, 
    94 no <tt class="docutils literal"><span class="pre">elem.attachEvent(...)</span></tt>, and certainly no <tt class="docutils literal"><span class="pre">elem.addEventListener(...)</span></tt>. 
    95 This also means that <a class="mochiref reference" href="DOM.html#fn-addtocallstack">MochiKit.DOM.addToCallStack</a> and 
     92<p>When using MochiKit.Signal, do not use the browser's native event API. 
     93That means, no <tt class="docutils literal"><span class="pre">onclick=&quot;blah&quot;</span></tt>, no <tt class="docutils literal"><span class="pre">elem.addEventListener(...)</span></tt>, and 
     94certainly no <tt class="docutils literal"><span class="pre">elem.attachEvent(...)</span></tt>. This also means that 
     95<a class="mochiref reference" href="DOM.html#fn-addtocallstack">MochiKit.DOM.addToCallStack</a> and 
    9696<a class="mochiref reference" href="DOM.html#fn-addloadevent">MochiKit.DOM.addLoadEvent</a> should not be used in combination with 
    9797this module.</p> 
    98 <p>Signals for DOM objects are named with the 'on' prefix, e.g.: 
    99 'onclick', 'onkeyup', etc.</p> 
    100 <p>When the signal fires, your slot will be called with exactly one parameter, 
    101 the custom event object.</p> 
     98<p>Signals for DOM objects are named with the <tt class="docutils literal"><span class="pre">on</span></tt> prefix, e.g.: <tt class="docutils literal"><span class="pre">onclick</span></tt>, 
     99<tt class="docutils literal"><span class="pre">onkeyup</span></tt>, etc.</p> 
     100<p>When the signal fires, your slot will be called with one parameter, the custom 
     101event object.</p> 
    102102</div> 
    103103<div class="section"> 
     
    107107across all supported platforms and browsers, and provides many conveniences 
    108108not available even in a correct W3C implementation.</p> 
    109 <p>Here is a complete list of this object's methods:</p> 
    110 <blockquote> 
    111 <p>These are always generated:</p> 
    112 <dl class="docutils"> 
    113 <dt>event():</dt> 
    114 <dd>The native event produced by the browser. You should not need to 
    115 access this.</dd> 
    116 <dt>type():</dt> 
    117 <dd>The event type: click, mouseover, keypress, etc. (Does not include 
    118 the 'on' prefix.)</dd> 
    119 <dt>target():</dt> 
    120 <dd>The element that triggered the event.</dd> 
    121 <dt>modifier().alt, modifier().ctrl, modifier().meta, modifier().shift:</dt> 
    122 <dd><tt class="docutils literal"><span class="pre">true</span></tt> if pressed, <tt class="docutils literal"><span class="pre">false</span></tt> if not. <tt class="docutils literal"><span class="pre">modifier().meta</span></tt> will be 
    123 <tt class="docutils literal"><span class="pre">false</span></tt> instead of <tt class="docutils literal"><span class="pre">undefined</span></tt> in IE.</dd> 
    124 <dt>modifier().any:</dt> 
    125 <dd><tt class="docutils literal"><span class="pre">true</span></tt> if any modifier is pressed, <tt class="docutils literal"><span class="pre">false</span></tt> if not.</dd> 
    126 <dt>stopPropagation():</dt> 
    127 <dd>Works like W3C's <tt class="docutils literal"><span class="pre">stopPropagation()</span></tt>.</dd> 
    128 <dt>preventDefault():</dt> 
    129 <dd>Works like W3C's <tt class="docutils literal"><span class="pre">preventDefault()</span></tt>.</dd> 
    130 <dt>stop():</dt> 
    131 <dd>Shortcut that calls <tt class="docutils literal"><span class="pre">stopPropagation()</span></tt> and <tt class="docutils literal"><span class="pre">preventDefault()</span></tt>.</dd> 
    132 </dl> 
    133 <p>You should use keydown and keyup to detect control characters, 
    134 and keypressed to detect &quot;printable&quot; characters. key().code will be set to 
    135 0 and key().string will be set to an empty string in a keypress handler if 
    136 a user presses a control character like F1 or Escape. IE will not fire 
    137 your keypressed handler when you press a control character like KEY_F1 or 
    138 KEY_ESCAPE. In your keyup and keydown handlers, Signal will pass the 
    139 keyboard code and a human-readable string like KEY_A or KEY_ARROW_DOWN or 
    140 KEY_NUM_PAD_ASTERISK. See <tt class="docutils literal"><span class="pre">_specialKeys</span></tt> for a comprehensive list. These 
    141 are generated for keydown and keyup events:</p> 
    142 <dl class="docutils"> 
    143 <dt>key().code:</dt> 
    144 <dd>contains the raw key code, such as 8 for backspace.</dd> 
    145 <dt>key().string:</dt> 
    146 <dd>contains a human readable string, such as 'KEY_BACKSPACE' or '!'. 
    147 The complete list is defined in MochiKit.Signal._specialKeys.</dd> 
    148 </dl> 
    149 <p>These are only generated for mouse*, click, dblclick, and contextmenu 
    150 (contextmenu doesn't work in Opera):</p> 
    151 <dl class="docutils"> 
    152 <dt>mouse().page.x, mouse().page.y:</dt> 
    153 <dd>represents the cursor position relative to the HTML document. 
    154 (Equivalent to pageX/Y in Safari, Mozilla, and Opera.)</dd> 
    155 <dt>mouse().client.x, mouse().client.y:</dt> 
    156 <dd>represents the cursor position relative to the visible portion of the 
    157 HTML document. (Equivalent to clientX/Y on all browsers.)</dd> 
    158 </dl> 
    159 <p>These are only generated for mouseup, mousedown, click, and dblclick:</p> 
    160 <dl class="docutils"> 
    161 <dt>mouse().button.left, mouse().button.right, mouse().button.middle:</dt> 
    162 <dd><p class="first"><tt class="docutils literal"><span class="pre">true</span></tt> or <tt class="docutils literal"><span class="pre">false</span></tt>. Mac browsers don't report right click 
    163 consistently. Firefox fires the click and sets modifier().ctrl to 
    164 true, Opera fires the click and sets modifier().meta to true, and 
    165 Safari doesn't fire the click (<a class="reference" href="http://bugzilla.opendarwin.org/show_bug.cgi?id=6595">Safari Bug 6595</a>).</p> 
    166 <p>If you want a right click, I suggest that instead of looking for 
    167 a right click, look for a contextmenu event.</p> 
    168 <p class="last">Current versions of Safari won't fire a dblclick event when attached 
    169 via <tt class="docutils literal"><span class="pre">connect()</span></tt> (<a class="reference" href="http://bugzilla.opendarwin.org/show_bug.cgi?id=7790">Safari Bug 7790</a>).</p> 
    170 </dd> 
    171 </dl> 
    172 <p>This is generated on mouseover and mouseout:</p> 
    173 <dl class="docutils"> 
    174 <dt>relatedTarget():</dt> 
    175 <dd>the document element that the mouse has moved to.</dd> 
    176 </dl> 
    177 </blockquote> 
    178109<p>If you find that you're accessing the native event for any reason, create a 
    179110<a class="reference" href="http://trac.mochikit.com/newticket">new ticket</a> and we'll look into normalizing the behavior you're looking for.</p> 
     
    184115by the Signal mechanism until it is disconnected via <a class="mochiref reference" href="#fn-disconnect">disconnect()</a> 
    185116or <a class="mochiref reference" href="#fn-disconnectall">disconnectAll()</a>.</p> 
    186 <p>Signal does not leak. It registers an 'onunload' event that disconnects all 
     117<p>Signal does not leak. It registers an <tt class="docutils literal"><span class="pre">onunload</span></tt> event that disconnects all 
    187118objects on the page when the browser leaves the page. However, memory usage 
    188119will grow during the page view for every connection made until it is 
    189120disconnected. Even if the DOM object is removed from the document, it 
    190121will still be referenced by Signal until it is explicitly disconnected.</p> 
    191 <p>In order to conserve memory during the page view, you should ensure to use 
    192 <a class="mochiref reference" href="#fn-disconnectall">disconnectAll()</a> any DOM elements that are about to be removed 
    193 from the document.</p> 
     122<p>In order to conserve memory during the page view, <a class="mochiref reference" href="#fn-disconnectall">disconnectAll()</a> 
     123any DOM elements that are about to be removed from the document.</p> 
    194124</div> 
    195125<div class="section"> 
     
    215145<h1><a id="api-reference" name="api-reference">API Reference</a></h1> 
    216146<div class="section"> 
    217 <h2><a id="functions" name="functions">Functions</a></h2> 
     147<h2><a id="signal-api-reference" name="signal-api-reference">Signal API Reference</a></h2> 
    218148<p> 
    219149<a name="fn-connect"></a> 
     
    223153used to disconnect that signal.</p> 
    224154<p><tt class="docutils literal"><span class="pre">src</span></tt> is the object that has the signal. You may pass in a string, in 
    225 which case, it is interpreted as an id for an HTML Element.</p> 
     155which case, it is interpreted as an id for an HTML element.</p> 
    226156<p><tt class="docutils literal"><span class="pre">signal</span></tt> is a string that represents a signal name. If 'src' is an HTML 
    227 Element, Window, or the Document, then it can be one of the 'on-XYZ' 
    228 events. You must include the 'on' prefix, and it must be all 
     157Element, <tt class="docutils literal"><span class="pre">window</span></tt>, or the <tt class="docutils literal"><span class="pre">document</span></tt>, then it can be one of the 
     158'on-XYZ' events. You must include the 'on' prefix, and it must be all 
    229159lower-case.</p> 
    230160<p><tt class="docutils literal"><span class="pre">dest</span></tt> and <tt class="docutils literal"><span class="pre">func</span></tt> describe the slot, or the action to take when the 
     
    243173</ul> 
    244174</blockquote> 
    245 <p>No other combinations are allowed and should raise and exception.</p> 
     175<p>No other combinations are allowed and will raise an exception.</p> 
    246176<p>The return value can be passed to <a class="mochiref reference" href="#fn-disconnect">disconnect</a> to disconnect 
    247177the signal.</p> 
     
    262192<a class="mochiref reference" href="#fn-connect">connect()</a>.</blockquote> 
    263193</div> 
     194<div class="section"> 
     195<h2><a id="dom-event-api-reference" name="dom-event-api-reference">DOM Event API Reference</a></h2> 
     196<dl class="docutils"> 
     197<dt> 
     198<a name="fn-event"></a> 
     199<a class="mochidef reference" href="#fn-event">event()</a>:</dt> 
     200<dd>The native event produced by the browser. You should not need to 
     201access this.</dd> 
     202<dt> 
     203<a name="fn-type"></a> 
     204<a class="mochidef reference" href="#fn-type">type()</a>:</dt> 
     205<dd>Returns the event type (<tt class="docutils literal"><span class="pre">click</span></tt>, <tt class="docutils literal"><span class="pre">mouseover</span></tt>, <tt class="docutils literal"><span class="pre">keypress</span></tt>, etc.) as a 
     206string. Does not include the <tt class="docutils literal"><span class="pre">on</span></tt> prefix.</dd> 
     207<dt> 
     208<a name="fn-target"></a> 
     209<a class="mochidef reference" href="#fn-target">target()</a>:</dt> 
     210<dd>Returns the element that triggered the event.</dd> 
     211<dt> 
     212<a name="fn-modifier"></a> 
     213<a class="mochidef reference" href="#fn-modifier">modifier()</a>:</dt> 
     214<dd>Returns <tt class="docutils literal"><span class="pre">{shift,</span> <span class="pre">ctrl,</span> <span class="pre">meta,</span> <span class="pre">alt,</span> <span class="pre">any}</span></tt>, where each property is <tt class="docutils literal"><span class="pre">true</span></tt> 
     215if its respective modifier key was pressed, <tt class="docutils literal"><span class="pre">false</span></tt> otherwise. <tt class="docutils literal"><span class="pre">any</span></tt> 
     216is <tt class="docutils literal"><span class="pre">true</span></tt> if any modifier is pressed, <tt class="docutils literal"><span class="pre">false</span></tt> otherwise.</dd> 
     217<dt> 
     218<a name="fn-stoppropagation"></a> 
     219<a class="mochidef reference" href="#fn-stoppropagation">stopPropagation()</a>:</dt> 
     220<dd>Works like W3C's <tt class="docutils literal"><span class="pre">stopPropagation()</span></tt>.</dd> 
     221<dt> 
     222<a name="fn-preventdefault"></a> 
     223<a class="mochidef reference" href="#fn-preventdefault">preventDefault()</a>:</dt> 
     224<dd>Works like W3C's <tt class="docutils literal"><span class="pre">preventDefault()</span></tt>.</dd> 
     225<dt> 
     226<a name="fn-stop"></a> 
     227<a class="mochidef reference" href="#fn-stop">stop()</a>:</dt> 
     228<dd>Shortcut that calls <tt class="docutils literal"><span class="pre">stopPropagation()</span></tt> and <tt class="docutils literal"><span class="pre">preventDefault()</span></tt>.</dd> 
     229<dt> 
     230<a name="fn-key"></a> 
     231<a class="mochidef reference" href="#fn-key">key()</a>:</dt> 
     232<dd><p class="first">Returns {code, string}.</p> 
     233<p>Use <tt class="docutils literal"><span class="pre">onkeydown</span></tt> and <tt class="docutils literal"><span class="pre">onkeyup</span></tt> handlers to detect control characters 
     234such as <tt class="docutils literal"><span class="pre">KEY_F1</span></tt>. Use the <tt class="docutils literal"><span class="pre">onkeypressed</span></tt> handler to detect &quot;printable&quot; 
     235characters, such as <tt class="docutils literal"><span class="pre">é</span></tt>.</p> 
     236<p>When a user presses F1, in <tt class="docutils literal"><span class="pre">onkeydown</span></tt> and <tt class="docutils literal"><span class="pre">onkeyup</span></tt> this method 
     237returns <tt class="docutils literal"><span class="pre">{code:</span> <span class="pre">122,</span> <span class="pre">string:</span> <span class="pre">'KEY_F1'}</span></tt>. In <tt class="docutils literal"><span class="pre">onkeypress</span></tt>, it returns 
     238<tt class="docutils literal"><span class="pre">{code:</span> <span class="pre">0,</span> <span class="pre">string:</span> <span class="pre">''}</span></tt>.</p> 
     239<p>If a user presses Shift+2 on a US keyboard, this method returns <tt class="docutils literal"><span class="pre">{code:</span> 
     240<span class="pre">50,</span> <span class="pre">string:</span> <span class="pre">'KEY_2'}</span></tt> in <tt class="docutils literal"><span class="pre">onkeydown</span></tt> and <tt class="docutils literal"><span class="pre">onkeyup</span></tt>. In 
     241<tt class="docutils literal"><span class="pre">onkeypress</span></tt>, it returns <tt class="docutils literal"><span class="pre">{code:</span> <span class="pre">64,</span> <span class="pre">string:</span> <span class="pre">'&#64;'}</span></tt>.</p> 
     242<p class="last">See <tt class="docutils literal"><span class="pre">_specialKeys</span></tt> for a comprehensive list of control characters.</p> 
     243</dd> 
     244<dt> 
     245<a name="fn-mouse"></a> 
     246<a class="mochidef reference" href="#fn-mouse">mouse()</a>:</dt> 
     247<dd><p class="first">Properties for <tt class="docutils literal"><span class="pre">onmouse*</span></tt>, <tt class="docutils literal"><span class="pre">onclick</span></tt>, <tt class="docutils literal"><span class="pre">ondblclick</span></tt>, and 
     248<tt class="docutils literal"><span class="pre">oncontextmenu</span></tt> events. (<tt class="docutils literal"><span class="pre">contextmenu</span></tt> doesn't work in Opera).</p> 
     249<blockquote> 
     250<ul class="simple"> 
     251<li><tt class="docutils literal"><span class="pre">page</span></tt> is a <a class="mochiref reference" href="DOM.html#fn-coordinates">MochiKit.DOM.Coordinates</a> object that 
     252represents the cursor position relative to the HTML document. 
     253Equivalent to <tt class="docutils literal"><span class="pre">pageX</span></tt> and <tt class="docutils literal"><span class="pre">pageY</span></tt> in Safari, Mozilla, and Opera.</li> 
     254<li><tt class="docutils literal"><span class="pre">client</span></tt> is a <a class="mochiref reference" href="DOM.html#fn-coordinates">MochiKit.DOM.Coordinates</a> object that 
     255represents the cursor position relative to the visible portion of 
     256the HTML document. Equivalent to <tt class="docutils literal"><span class="pre">clientX</span></tt> and <tt class="docutils literal"><span class="pre">clientY</span></tt> on 
     257all browsers.</li> 
     258</ul> 
     259</blockquote> 
     260<p>Properties for <tt class="docutils literal"><span class="pre">onmouseup</span></tt>, <tt class="docutils literal"><span class="pre">onmousedown</span></tt>, <tt class="docutils literal"><span class="pre">onclick</span></tt>, and 
     261<tt class="docutils literal"><span class="pre">ondblclick</span></tt>:</p> 
     262<blockquote> 
     263<ul class="simple"> 
     264<li><tt class="docutils literal"><span class="pre">mouse().button</span></tt> returns {left, right, middle} where each 
     265property is <tt class="docutils literal"><span class="pre">true</span></tt> if the mouse button was pressed, <tt class="docutils literal"><span class="pre">false</span></tt> 
     266otherwise.</li> 
     267</ul> 
     268</blockquote> 
     269<p>Mac browsers don't report right click consistently. Firefox fires the 
     270click and sets <tt class="docutils literal"><span class="pre">modifier().ctrl</span></tt> to true, Opera fires the click and sets 
     271<tt class="docutils literal"><span class="pre">modifier().meta</span></tt> to <tt class="docutils literal"><span class="pre">true</span></tt>, and Safari doesn't fire the click 
     272(<a class="reference" href="http://bugzilla.opendarwin.org/show_bug.cgi?id=6595">Safari Bug 6595</a>).</p> 
     273<p>If you want a right click, we suggest that instead of looking for a right 
     274click, look for a <tt class="docutils literal"><span class="pre">contextmenu</span></tt> event.</p> 
     275<p class="last">Current versions of Safari won't fire a <tt class="docutils literal"><span class="pre">dblclick</span></tt> event when attached 
     276via <tt class="docutils literal"><span class="pre">connect()</span></tt> (<a class="reference" href="http://bugzilla.opendarwin.org/show_bug.cgi?id=7790">Safari Bug 7790</a>).</p> 
     277</dd> 
     278<dt> 
     279<a name="fn-relatedtarget"></a> 
     280<a class="mochidef reference" href="#fn-relatedtarget">relatedTarget()</a>:</dt> 
     281<dd>This is generated on <tt class="docutils literal"><span class="pre">mouseover</span></tt> and <tt class="docutils literal"><span class="pre">mouseout</span></tt>. Returns the document 
     282element that the mouse has moved to.</dd> 
     283</dl> 
     284</div> 
    264285</div> 
    265286<div class="section"> 
  • mochikit/trunk/doc/rst/MochiKit/Signal.rst

    r742 r750  
    6868This module takes care of all the hard work |---| figuring out which event 
    6969model to use, trying to retrieve the event object, and handling your own 
    70 internal events, as well as cleanup when the page is unloaded to handle IE's 
     70internal events, as well as cleanup when the page is unloaded to clean up IE's 
    7171nasty memory leakage. 
    7272 
    73 This event system is largely based on Qt's signal/slot system. You should read 
    74 more on how that is handled and also how it is used in model/view programming 
    75 at: http://doc.trolltech.com/ 
     73This event system is largely based on Qt's signal/slot system. Read more on 
     74how that is handled and also how it is used in model/view programming at: 
     75http://doc.trolltech.com/ 
    7676 
    7777 
     
    8989--------------------------- 
    9090 
    91 When using MochiKit.Signal, you should not directly use the browser's native 
    92 event handling for the same events. That means, no ``onclick="blah"``,  
    93 no ``elem.attachEvent(...)``, and certainly no ``elem.addEventListener(...)``. 
    94 This also means that :mochiref:`MochiKit.DOM.addToCallStack` and 
     91When using MochiKit.Signal, do not use the browser's native event API. 
     92That means, no ``onclick="blah"``, no ``elem.addEventListener(...)``, and 
     93certainly no ``elem.attachEvent(...)``. This also means that 
     94:mochiref:`MochiKit.DOM.addToCallStack` and 
    9595:mochiref:`MochiKit.DOM.addLoadEvent` should not be used in combination with 
    9696this module. 
    9797 
    98 Signals for DOM objects are named with the 'on' prefix, e.g.: 
    99 'onclick', 'onkeyup', etc. 
    100  
    101 When the signal fires, your slot will be called with exactly one parameter, 
    102 the custom event object. 
     98Signals for DOM objects are named with the ``on`` prefix, e.g.: ``onclick``, 
     99``onkeyup``, etc. 
     100 
     101When the signal fires, your slot will be called with one parameter, the custom 
     102event object. 
    103103 
    104104 
     
    111111not available even in a correct W3C implementation. 
    112112 
    113 Here is a complete list of this object's methods: 
    114  
    115     These are always generated: 
    116  
    117     event(): 
    118         The native event produced by the browser. You should not need to 
    119         access this. 
    120  
    121     type(): 
    122         The event type: click, mouseover, keypress, etc. (Does not include 
    123         the 'on' prefix.) 
    124  
    125     target(): 
    126         The element that triggered the event. 
    127  
    128     modifier().alt, modifier().ctrl, modifier().meta, modifier().shift: 
    129         ``true`` if pressed, ``false`` if not. ``modifier().meta`` will be  
    130         ``false`` instead of ``undefined`` in IE. 
    131          
    132     modifier().any: 
    133         ``true`` if any modifier is pressed, ``false`` if not. 
    134  
    135     stopPropagation(): 
    136         Works like W3C's ``stopPropagation()``. 
    137          
    138     preventDefault(): 
    139         Works like W3C's ``preventDefault()``. 
    140          
    141     stop(): 
    142         Shortcut that calls ``stopPropagation()`` and ``preventDefault()``. 
    143  
    144     You should use keydown and keyup to detect control characters, 
    145     and keypressed to detect "printable" characters. key().code will be set to 
    146     0 and key().string will be set to an empty string in a keypress handler if 
    147     a user presses a control character like F1 or Escape. IE will not fire 
    148     your keypressed handler when you press a control character like KEY_F1 or 
    149     KEY_ESCAPE. In your keyup and keydown handlers, Signal will pass the 
    150     keyboard code and a human-readable string like KEY_A or KEY_ARROW_DOWN or 
    151     KEY_NUM_PAD_ASTERISK. See ``_specialKeys`` for a comprehensive list. These 
    152     are generated for keydown and keyup events: 
    153  
    154     key().code: 
    155         contains the raw key code, such as 8 for backspace. 
    156  
    157     key().string: 
    158         contains a human readable string, such as 'KEY_BACKSPACE' or '!'. 
    159         The complete list is defined in MochiKit.Signal._specialKeys. 
    160  
    161     These are only generated for mouse*, click, dblclick, and contextmenu 
    162     (contextmenu doesn't work in Opera): 
    163  
    164     mouse().page.x, mouse().page.y: 
    165         represents the cursor position relative to the HTML document.  
    166         (Equivalent to pageX/Y in Safari, Mozilla, and Opera.) 
    167          
    168     mouse().client.x, mouse().client.y: 
    169         represents the cursor position relative to the visible portion of the 
    170         HTML document. (Equivalent to clientX/Y on all browsers.) 
    171      
    172     These are only generated for mouseup, mousedown, click, and dblclick: 
    173  
    174     mouse().button.left, mouse().button.right, mouse().button.middle: 
    175         ``true`` or ``false``. Mac browsers don't report right click 
    176         consistently. Firefox fires the click and sets modifier().ctrl to 
    177         true, Opera fires the click and sets modifier().meta to true, and 
    178         Safari doesn't fire the click (`Safari Bug 6595`_). 
    179  
    180         If you want a right click, I suggest that instead of looking for 
    181         a right click, look for a contextmenu event. 
    182          
    183         Current versions of Safari won't fire a dblclick event when attached 
    184         via ``connect()`` (`Safari Bug 7790`_). 
    185  
    186     This is generated on mouseover and mouseout: 
    187  
    188     relatedTarget(): 
    189         the document element that the mouse has moved to. 
    190  
    191113If you find that you're accessing the native event for any reason, create a 
    192114`new ticket`_ and we'll look into normalizing the behavior you're looking for. 
     
    204126or :mochiref:`disconnectAll()`. 
    205127 
    206 Signal does not leak. It registers an 'onunload' event that disconnects all 
     128Signal does not leak. It registers an ``onunload`` event that disconnects all 
    207129objects on the page when the browser leaves the page. However, memory usage 
    208130will grow during the page view for every connection made until it is 
     
    210132will still be referenced by Signal until it is explicitly disconnected. 
    211133 
    212 In order to conserve memory during the page view, you should ensure to use 
    213 :mochiref:`disconnectAll()` any DOM elements that are about to be removed 
    214 from the document. 
     134In order to conserve memory during the page view, :mochiref:`disconnectAll()` 
     135any DOM elements that are about to be removed from the document. 
    215136 
    216137 
     
    240161============= 
    241162 
    242 Functions 
    243 --------- 
     163 
     164Signal API Reference 
     165-------------------- 
    244166 
    245167:mochidef:`connect(src, signal, dest[, func])`: 
     
    249171 
    250172    ``src`` is the object that has the signal. You may pass in a string, in 
    251     which case, it is interpreted as an id for an HTML Element. 
     173    which case, it is interpreted as an id for an HTML element. 
    252174 
    253175    ``signal`` is a string that represents a signal name. If 'src' is an HTML 
    254     Element, Window, or the Document, then it can be one of the 'on-XYZ' 
    255     events. You must include the 'on' prefix, and it must be all 
     176    Element, ``window``, or the ``document``, then it can be one of the 
     177    'on-XYZ' events. You must include the 'on' prefix, and it must be all 
    256178    lower-case. 
    257179 
     
    271193            signalled. 
    272194 
    273     No other combinations are allowed and should raise and exception. 
     195    No other combinations are allowed and will raise an exception. 
    274196 
    275197    The return value can be passed to :mochiref:`disconnect` to disconnect 
     
    289211    the connected slots. ``src`` and ``signal`` are the same as for 
    290212    :mochiref:`connect()`. 
     213 
     214 
     215DOM Event API Reference 
     216----------------------- 
     217 
     218:mochidef:`event()`: 
     219    The native event produced by the browser. You should not need to 
     220    access this. 
     221 
     222:mochidef:`type()`: 
     223    Returns the event type (``click``, ``mouseover``, ``keypress``, etc.) as a 
     224    string. Does not include the ``on`` prefix. 
     225 
     226:mochidef:`target()`: 
     227    Returns the element that triggered the event. 
     228 
     229:mochidef:`modifier()`: 
     230    Returns ``{shift, ctrl, meta, alt, any}``, where each property is ``true`` 
     231    if its respective modifier key was pressed, ``false`` otherwise. ``any`` 
     232    is ``true`` if any modifier is pressed, ``false`` otherwise. 
     233     
     234:mochidef:`stopPropagation()`: 
     235    Works like W3C's ``stopPropagation()``. 
     236     
     237:mochidef:`preventDefault()`: 
     238    Works like W3C's ``preventDefault()``. 
     239     
     240:mochidef:`stop()`: 
     241    Shortcut that calls ``stopPropagation()`` and ``preventDefault()``. 
     242 
     243:mochidef:`key()`: 
     244    Returns {code, string}. 
     245     
     246    Use ``onkeydown`` and ``onkeyup`` handlers to detect control characters 
     247    such as ``KEY_F1``. Use the ``onkeypressed`` handler to detect "printable" 
     248    characters, such as ``é``. 
     249     
     250    When a user presses F1, in ``onkeydown`` and ``onkeyup`` this method 
     251    returns ``{code: 122, string: 'KEY_F1'}``. In ``onkeypress``, it returns 
     252    ``{code: 0, string: ''}``. 
     253     
     254    If a user presses Shift+2 on a US keyboard, this method returns ``{code: 
     255    50, string: 'KEY_2'}`` in ``onkeydown`` and ``onkeyup``. In 
     256    ``onkeypress``, it returns ``{code: 64, string: '@'}``. 
     257         
     258    See ``_specialKeys`` for a comprehensive list of control characters. 
     259 
     260:mochidef:`mouse()`: 
     261    Properties for ``onmouse*``, ``onclick``, ``ondblclick``, and 
     262    ``oncontextmenu`` events. (``contextmenu`` doesn't work in Opera). 
     263 
     264        -   ``page`` is a :mochiref:`MochiKit.DOM.Coordinates` object that 
     265            represents the cursor position relative to the HTML document.  
     266            Equivalent to ``pageX`` and ``pageY`` in Safari, Mozilla, and Opera. 
     267 
     268        -   ``client`` is a :mochiref:`MochiKit.DOM.Coordinates` object that 
     269            represents the cursor position relative to the visible portion of  
     270            the HTML document. Equivalent to ``clientX`` and ``clientY`` on  
     271            all browsers. 
     272 
     273    Properties for ``onmouseup``, ``onmousedown``, ``onclick``, and 
     274    ``ondblclick``: 
     275 
     276        -   ``mouse().button`` returns {left, right, middle} where each  
     277            property is ``true`` if the mouse button was pressed, ``false``  
     278            otherwise. 
     279 
     280    Mac browsers don't report right click consistently. Firefox fires the 
     281    click and sets ``modifier().ctrl`` to true, Opera fires the click and sets 
     282    ``modifier().meta`` to ``true``, and Safari doesn't fire the click 
     283    (`Safari Bug 6595`_). 
     284 
     285    If you want a right click, we suggest that instead of looking for a right 
     286    click, look for a ``contextmenu`` event. 
     287 
     288    Current versions of Safari won't fire a ``dblclick`` event when attached 
     289    via ``connect()`` (`Safari Bug 7790`_). 
     290 
     291 
     292:mochidef:`relatedTarget()`: 
     293    This is generated on ``mouseover`` and ``mouseout``. Returns the document 
     294    element that the mouse has moved to. 
    291295 
    292296