1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7 <meta http-equiv="content-type" content="text/html; charset=undefined" />
8 <meta name="generator" content="JsDoc Toolkit" />
11 <title>JsDoc Reference - Roo.KeyMap</title>
14 <link rel="stylesheet" type="text/css" href="../../css/roojs.css" />
15 <link rel="stylesheet" type="text/css" href="../default.css" />
18 <script type="text/javascript" src="../page.js">
25 <body onload="RooDocsPage.onload();">
28 <div class="body-wrap">
30 <!-- ============================== links to methods. ================================= -->
32 <div class="top-tools">
34 <a class="inner-link" href="#Roo.KeyMap-props"><img src="resources/s.gif" class="item-icon icon-prop">Properties</a>
35 <a class="inner-link" href="#Roo.KeyMap-methods"><img src="resources/s.gif" class="item-icon icon-method">Methods</a>
36 <a class="inner-link" href="#Roo.KeyMap-events"><img src="resources/s.gif" class="item-icon icon-event">Events</a>
37 <a class="inner-link" href="#Roo.KeyMap-configs"><img src="resources/s.gif" class="item-icon icon-config">Config Options</a>
38 <a class="bookmark" href="NEED_TO_CREATE_DIRECT_LINK_HREF"><img src="resources/s.gif" class="item-icon icon-fav">Direct Link</a>
43 <!-- ============================== inheritance Block. ================================= -->
45 <!-- ============================== class title / details ============================ -->
48 <h1 class="classTitle">
53 <table cellspacing="0" class="class-summary-table">
55 <tr><td class="label">Package:</td><td class="hd-info">Roo</td></tr>
57 <tr><td class="label">Defined In:</td><td class="hd-info">
59 <a href="./src/Roo_KeyMap.js.html">Roo/KeyMap.js</a>.
62 <tr><td class="label">Class:</td><td class="hd-info">KeyMap</td></tr>
70 <!-- ============================== class summary ========================== -->
71 <div class="description">
72 Handles mapping keys to actions for an element. One key map can be used for multiple actions.<br/>The constructor accepts the same config object as defined by {<b>link</b> <b>addBinding</b>}.<br/>If you bind a callback function to a KeyMap, anytime the KeyMap handles an expected key<br/>combination it will call the function with this signature (if the match is a multi-key<br/>combination the callback will still be called only once): (String key, Roo.EventObject e)<br/>A KeyMap can also handle a string representation of keys.<br /><br/>Usage:<br/> <pre><code><br/>// map one key by key code<br/>var map = new Roo.KeyMap("my-element", {<br/> key: 13, // or Roo.EventObject.ENTER<br/> fn: myHandler,<br/> scope: myObject<br/>});<br/><br/>// map multiple keys to one action by string<br/>var map = new Roo.KeyMap("my-element", {<br/> key: "a\r\n\t",<br/> fn: myHandler,<br/> scope: myObject<br/>});<br/><br/>// map multiple keys to multiple actions by strings and array of codes<br/>var map = new Roo.KeyMap("my-element", [<br/> {<br/> key: [10,13],<br/> fn: function(){ alert("Return was pressed"); }<br/> }, {<br/> key: "abc",<br/> fn: function(){ alert('a, b or c was pressed'); }<br/> }, {<br/> key: "\t",<br/> ctrl:true,<br/> shift:true,<br/> fn: function(){ alert('Control + shift + tab was pressed.'); }<br/> }<br/>]);<br/></code></pre><br/><b>Note: A KeyMap starts enabled</b>
76 <!-- ============================== Class comment block... ========================== -->
78 <div class="comments">
79 <b>Class Comments / Notes</B> =>
80 <u onclick="parent.CommentDialog.showCommentId = 'Roo.KeyMap';">[Add Your comment/notes about this class]</u>
82 <iframe frameborder="0" id="comments-Roo" style="border: none;width:100%;"
83 src="/blog.php/GtkDjsComments/Roo.KeyMap.html"></iframe>
88 <!-- ============================== config options ========================== -->
93 <div class="hr"></div>
94 <a id="Roo.KeyMap-configs"></a>
98 <table cellspacing="0" class="member-table">
99 <caption class="Empty">Config Options - Has None</caption>
113 <!-- ============================== public properties ==================== -->
117 <a id="Roo.KeyMap-props"></a>
123 <table cellspacing="0" class="member-table">
124 <caption class="Empty">Public Properties - Has None</caption>
130 <!-- ============================== methods summary / details ======================== -->
133 <a id="Roo.KeyMap-methods"></a>
134 <!-- constructor?? -->
141 <!-- then dynamics first -->
148 <table cellspacing="0" class="member-table">
149 <caption>Public Methods</caption>
151 <th class="sig-header" colspan="2">Method</th>
152 <th class="msource-header">Defined By</th>
162 <tr class="method-row config-row-alt0 expandable notInherited">
163 <td class="micon"><a class="exi" href="#expand"> </a></td>
167 <a id="Roo-method-KeyMap" name=".KeyMap"></a>
168 <div class="fixedFont">
169 <span class="attributes">new <B>Roo.</B></span><b class="itemname">KeyMap</b>
171 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element <B><i>el</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a> <B><i>config</i></B>, <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>eventName</i></B>)
179 <div class="short">Create a new Roo.KeyMap</div>
186 Create a new Roo.KeyMap
189 <dl class="detailList">
190 <dt class="heading">Parameters:</dt>
193 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Roo.Element</span> <b>el</b>
196 <dd>The element to bind to</dd>
199 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a></span> <b>config</b>
202 <dd>The config (see {<b>link</b> <b>addBinding</b>})</dd>
205 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span> <b>eventName</b>
208 <dd>(optional) The event to bind to (defaults to "keydown")</dd>
232 <tr class="method-row config-row-alt1 expandable notInherited">
233 <td class="micon"><a class="exi" href="#expand"> </a></td>
237 <a id="Roo.KeyMap-method-addBinding" name=".addBinding"></a>
238 <div class="fixedFont">
239 <span class="attributes"></span><b class="itemname">addBinding</b>
241 (<a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a>/Array <B><i>config</i></B>)
248 <div class="short">Add a new binding to this KeyMap.</div>
254 Add a new binding to this KeyMap. The following config object properties are supported:<br/><pre><br/>Property Type Description<br/>---------- --------------- ----------------------------------------------------------------------<br/>key String/Array A single keycode or an array of keycodes to handle<br/>shift Boolean True to handle key only when shift is pressed (defaults to false)<br/>ctrl Boolean True to handle key only when ctrl is pressed (defaults to false)<br/>alt Boolean True to handle key only when alt is pressed (defaults to false)<br/>fn Function The function to call when KeyMap finds the expected key combination<br/>scope Object The scope of the callback function<br/></pre><br/><br/>Usage:<br/><pre><code><br/>// Create a KeyMap<br/>var map = new Roo.KeyMap(document, {<br/> key: Roo.EventObject.ENTER,<br/> fn: handleKey,<br/> scope: this<br/>});<br/><br/>//Add a new binding to the existing KeyMap later<br/>map.addBinding({<br/> key: 'abc',<br/> shift: true,<br/> fn: handleKey,<br/> scope: this<br/>});<br/></code></pre>
261 <dl class="detailList">
262 <dt class="heading">Parameters:</dt>
265 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a>/Array</span> <b>config</b>
268 <dd>A single KeyMap config or an array of configs</dd>
294 <tr class="method-row config-row-alt0 expandable notInherited">
295 <td class="micon"><a class="exi" href="#expand"> </a></td>
299 <a id="Roo.KeyMap-method-disable" name=".disable"></a>
300 <div class="fixedFont">
301 <span class="attributes"></span><b class="itemname">disable</b>
310 <div class="short">Disable this KeyMap</div>
345 <tr class="method-row config-row-alt1 expandable notInherited">
346 <td class="micon"><a class="exi" href="#expand"> </a></td>
350 <a id="Roo.KeyMap-method-enable" name=".enable"></a>
351 <div class="fixedFont">
352 <span class="attributes"></span><b class="itemname">enable</b>
361 <div class="short">Enables this KeyMap</div>
396 <tr class="method-row config-row-alt0 expandable notInherited">
397 <td class="micon"><a class="exi" href="#expand"> </a></td>
401 <a id="Roo.KeyMap-method-isEnabled" name=".isEnabled"></a>
402 <div class="fixedFont">
403 <span class="attributes"></span><b class="itemname">isEnabled</b>
411 <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a>
420 <div class="short">Returns true if this KeyMap is enabled</div>
426 Returns true if this KeyMap is enabled
437 <dl class="detailList">
438 <dt class="heading">Returns:</dt>
440 <dd><span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a></span> </dd>
462 <tr class="method-row config-row-alt1 expandable notInherited">
463 <td class="micon"><a class="exi" href="#expand"> </a></td>
467 <a id="Roo.KeyMap-method-on" name=".on"></a>
468 <div class="fixedFont">
469 <span class="attributes"></span><b class="itemname">on</b>
471 (<a href="./Number.html#constructor" roo:cls="Number.html#constructor">Number</a>/Array/Object <B><i>key</i></B>, <a href="./Function.html#constructor" roo:cls="Function.html#constructor">Function</a> <B><i>fn</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a> <B><i>scope</i></B>)
478 <div class="short">Shorthand for adding a single key listener</div>
484 Shorthand for adding a single key listener
491 <dl class="detailList">
492 <dt class="heading">Parameters:</dt>
495 <span class="fixedFont"><a href="./Number.html#constructor" roo:cls="Number.html#constructor">Number</a>/Array/Object</span> <b>key</b>
498 <dd>Either the numeric key code, array of key codes or an object with the<br/>following options:<br/>{key: (number or array), shift: (true/false), ctrl: (true/false), alt: (true/false)}</dd>
501 <span class="fixedFont"><a href="./Function.html#constructor" roo:cls="Function.html#constructor">Function</a></span> <b>fn</b>
504 <dd>The function to call</dd>
507 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object">Object</a></span> <b>scope</b>
510 <dd>(optional) The scope of the function</dd>
539 <!-- ============================== events summary / details ======================== -->
542 <a id="Roo.KeyMap-events"></a>
548 <table cellspacing="0" class="member-table">
549 <caption class="Empty">Events - Has None</caption>
560 <!-- ============================== footer ================================= -->
561 <div class="fineprint" style="clear:both">
563 Documentation generated by <a href="http://www.akbkhome.com" target="_blankt">Introspection Doc Generator</a> on Fri Jan 14 2011 17:01:48 GMT+0800 (HKT)
565 <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a>