4f1f4bab0a5f0cd346938421c4435e13ae1266b3.svn-base 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <div class="body-wrap">
  2. <div class="top-tools">
  3. <a class="inner-link" href="#Ext.KeyMap-props"><img src="../resources/images/default/s.gif" class="item-icon icon-prop">Properties</a>
  4. <a class="inner-link" href="#Ext.KeyMap-methods"><img src="../resources/images/default/s.gif" class="item-icon icon-method">Methods</a>
  5. <a class="inner-link" href="#Ext.KeyMap-events"><img src="../resources/images/default/s.gif" class="item-icon icon-event">Events</a>
  6. <a class="bookmark" href="../docs/?class=Ext.KeyMap"><img src="../resources/images/default/s.gif" class="item-icon icon-fav">Direct Link</a>
  7. </div>
  8. <h1>Class Ext.KeyMap</h1>
  9. <table cellspacing="0">
  10. <tr><td class="label">Package:</td><td class="hd-info">Ext</td></tr>
  11. <tr><td class="label">Defined In:</td><td class="hd-info"><a href="../src/KeyMap.js" target="_blank">KeyMap.js</a></td></tr>
  12. <tr><td class="label">Class:</td><td class="hd-info">KeyMap</td></tr>
  13. <tr><td class="label">Extends:</td><td class="hd-info">Object</td></tr>
  14. </table>
  15. <div class="description">
  16. Handles mapping keys to actions for an element. One key map can be used for multiple actions.
  17. The constructor accepts the same config object as defined by <a ext:cls="Ext.KeyMap" ext:member="addBinding" href="output/Ext.KeyMap.html#addBinding">addBinding</a>.
  18. If you bind a callback function to a KeyMap, anytime the KeyMap handles an expected key
  19. combination it will call the function with this signature (if the match is a multi-key
  20. combination the callback will still be called only once): (String key, Ext.EventObject e)
  21. A KeyMap can also handle a string representation of keys.<br />
  22. Usage:
  23. <pre><code><i>// map one key by key code</i>
  24. <b>var</b> map = <b>new</b> Ext.KeyMap(<em>"my-element"</em>, {
  25. key: 13, <i>// or Ext.EventObject.ENTER</i>
  26. fn: myHandler,
  27. scope: myObject
  28. });
  29. <i>// map multiple keys to one action by string</i>
  30. <b>var</b> map = <b>new</b> Ext.KeyMap(<em>"my-element"</em>, {
  31. key: <em>"a\r\n\t"</em>,
  32. fn: myHandler,
  33. scope: myObject
  34. });
  35. <i>// map multiple keys to multiple actions by strings and array of codes</i>
  36. <b>var</b> map = <b>new</b> Ext.KeyMap(<em>"my-element"</em>, [
  37. {
  38. key: [10,13],
  39. fn: <b>function</b>(){ alert(<em>"Return was pressed"</em>); }
  40. }, {
  41. key: <em>"abc"</em>,
  42. fn: <b>function</b>(){ alert(<em>'a, b or c was pressed'</em>); }
  43. }, {
  44. key: <em>"\t"</em>,
  45. ctrl:true,
  46. shift:true,
  47. fn: <b>function</b>(){ alert(<em>'Control + shift + tab was pressed.'</em>); }
  48. }
  49. ]);</code></pre>
  50. <b>Note: A KeyMap starts enabled</b> </div>
  51. <div class="hr"></div>
  52. <a id="Ext.KeyMap-props"></a>
  53. <h2>Public Properties</h2>
  54. <table cellspacing="0" class="member-table">
  55. <tr>
  56. <th class="sig-header" colspan="2">Property</th>
  57. <th class="msource-header">Defined By</th>
  58. </tr>
  59. <tr class="property-row expandable">
  60. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  61. <td class="sig">
  62. <a id="Ext.KeyMap-stopEvent"></a>
  63. <b>stopEvent</b> : Boolean <div class="mdesc">
  64. <div class="short">True to stop the event from bubbling and prevent the default browser action if the
  65. key was handled by the KeyMap (def...</div>
  66. <div class="long">
  67. True to stop the event from bubbling and prevent the default browser action if the
  68. key was handled by the KeyMap (defaults to false) </div>
  69. </div>
  70. </td>
  71. <td class="msource">KeyMap</td>
  72. </tr>
  73. </table>
  74. <a id="Ext.KeyMap-methods"></a>
  75. <h2>Public Methods</h2>
  76. <table cellspacing="0" class="member-table">
  77. <tr>
  78. <th class="sig-header" colspan="2">Method</th>
  79. <th class="msource-header">Defined By</th>
  80. </tr>
  81. <tr class="method-row expandable">
  82. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  83. <td class="sig">
  84. <a id="Ext.KeyMap-KeyMap"></a>
  85. <b>KeyMap</b>(&nbsp;<code>Mixed el</code>, <code>Object config</code>, <span class="optional" title="Optional">[<code>String eventName</code>]</span>&nbsp;) <div class="mdesc">
  86. <div class="short"></div>
  87. <div class="long">
  88. <div class="mdetail-params">
  89. <strong>Parameters:</strong>
  90. <ul><li><code>el</code> : Mixed<div class="sub-desc">The element to bind to</div></li><li><code>config</code> : Object<div class="sub-desc">The config (see <a ext:cls="Ext.KeyMap" ext:member="addBinding" href="output/Ext.KeyMap.html#addBinding">addBinding</a>)</div></li><li><code>eventName</code> : String<div class="sub-desc">(optional) The event to bind to (defaults to "keydown")</div></li> </ul>
  91. <strong>Returns:</strong>
  92. <ul>
  93. <li><code></code></li>
  94. </ul>
  95. </div>
  96. </div>
  97. </div>
  98. </td>
  99. <td class="msource">KeyMap</td>
  100. </tr>
  101. <tr class="method-row alt expandable">
  102. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  103. <td class="sig">
  104. <a id="Ext.KeyMap-addBinding"></a>
  105. <b>addBinding</b>(&nbsp;<code>Object/Array config</code>&nbsp;) : void <div class="mdesc">
  106. <div class="short">Add a new binding to this KeyMap. The following config object properties are supported:
  107. Property Type ...</div>
  108. <div class="long">
  109. Add a new binding to this KeyMap. The following config object properties are supported:
  110. <pre>Property Type Description
  111. ---------- --------------- ----------------------------------------------------------------------
  112. key String/Array A single keycode or an array of keycodes to handle
  113. shift Boolean True to handle key only when shift is pressed (defaults to false)
  114. ctrl Boolean True to handle key only when ctrl is pressed (defaults to false)
  115. alt Boolean True to handle key only when alt is pressed (defaults to false)
  116. handler Function The function to call when KeyMap finds the expected key combination
  117. fn Function Alias of handler (for backwards-compatibility)
  118. scope Object The scope of the callback function</pre>
  119. Usage:
  120. <pre><code><i>// Create a KeyMap</i>
  121. <b>var</b> map = <b>new</b> Ext.KeyMap(document, {
  122. key: Ext.EventObject.ENTER,
  123. fn: handleKey,
  124. scope: <b>this</b>
  125. });
  126. <i>//Add a <b>new</b> binding to the existing KeyMap later</i>
  127. map.addBinding({
  128. key: <em>'abc'</em>,
  129. shift: true,
  130. fn: handleKey,
  131. scope: <b>this</b>
  132. });</code></pre> <div class="mdetail-params">
  133. <strong>Parameters:</strong>
  134. <ul><li><code>config</code> : Object/Array<div class="sub-desc">A single KeyMap config or an array of configs</div></li> </ul>
  135. <strong>Returns:</strong>
  136. <ul>
  137. <li><code>void</code></li>
  138. </ul>
  139. </div>
  140. </div>
  141. </div>
  142. </td>
  143. <td class="msource">KeyMap</td>
  144. </tr>
  145. <tr class="method-row expandable">
  146. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  147. <td class="sig">
  148. <a id="Ext.KeyMap-disable"></a>
  149. <b>disable</b>() : void <div class="mdesc">
  150. <div class="short">Disable this KeyMap</div>
  151. <div class="long">
  152. Disable this KeyMap <div class="mdetail-params">
  153. <strong>Parameters:</strong>
  154. <ul><li>None.</li> </ul>
  155. <strong>Returns:</strong>
  156. <ul>
  157. <li><code>void</code></li>
  158. </ul>
  159. </div>
  160. </div>
  161. </div>
  162. </td>
  163. <td class="msource">KeyMap</td>
  164. </tr>
  165. <tr class="method-row alt expandable">
  166. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  167. <td class="sig">
  168. <a id="Ext.KeyMap-enable"></a>
  169. <b>enable</b>() : void <div class="mdesc">
  170. <div class="short">Enables this KeyMap</div>
  171. <div class="long">
  172. Enables this KeyMap <div class="mdetail-params">
  173. <strong>Parameters:</strong>
  174. <ul><li>None.</li> </ul>
  175. <strong>Returns:</strong>
  176. <ul>
  177. <li><code>void</code></li>
  178. </ul>
  179. </div>
  180. </div>
  181. </div>
  182. </td>
  183. <td class="msource">KeyMap</td>
  184. </tr>
  185. <tr class="method-row expandable">
  186. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  187. <td class="sig">
  188. <a id="Ext.KeyMap-isEnabled"></a>
  189. <b>isEnabled</b>() : Boolean <div class="mdesc">
  190. <div class="short">Returns true if this KeyMap is enabled</div>
  191. <div class="long">
  192. Returns true if this KeyMap is enabled <div class="mdetail-params">
  193. <strong>Parameters:</strong>
  194. <ul><li>None.</li> </ul>
  195. <strong>Returns:</strong>
  196. <ul>
  197. <li><code>Boolean</code></li>
  198. </ul>
  199. </div>
  200. </div>
  201. </div>
  202. </td>
  203. <td class="msource">KeyMap</td>
  204. </tr>
  205. <tr class="method-row alt expandable">
  206. <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>
  207. <td class="sig">
  208. <a id="Ext.KeyMap-on"></a>
  209. <b>on</b>(&nbsp;<code>Number/Array/Object key</code>, <code>Function fn</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>&nbsp;) : void <div class="mdesc">
  210. <div class="short">Shorthand for adding a single key listener</div>
  211. <div class="long">
  212. Shorthand for adding a single key listener <div class="mdetail-params">
  213. <strong>Parameters:</strong>
  214. <ul><li><code>key</code> : Number/Array/Object<div class="sub-desc">Either the numeric key code, array of key codes or an object with the
  215. following options:
  216. {key: (number or array), shift: (true/false), ctrl: (true/false), alt: (true/false)}</div></li><li><code>fn</code> : Function<div class="sub-desc">The function to call</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope of the function</div></li> </ul>
  217. <strong>Returns:</strong>
  218. <ul>
  219. <li><code>void</code></li>
  220. </ul>
  221. </div>
  222. </div>
  223. </div>
  224. </td>
  225. <td class="msource">KeyMap</td>
  226. </tr>
  227. </table>
  228. <a id="Ext.KeyMap-events"></a>
  229. <h2>Public Events</h2>
  230. <div class="no-members">This class has no public events.</div>
  231. </div>