2 |
aperonnet |
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="../source/util/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 |
|
|
|
30 |
<i>// map multiple keys to one action by string</i>
|
|
|
31 |
<b>var</b> map = <b>new</b> Ext.KeyMap(<em>"my-element"</em>, {
|
|
|
32 |
key: <em>"a\r\n\t"</em>,
|
|
|
33 |
fn: myHandler,
|
|
|
34 |
scope: myObject
|
|
|
35 |
});
|
|
|
36 |
|
|
|
37 |
<i>// map multiple keys to multiple actions by strings and array of codes</i>
|
|
|
38 |
<b>var</b> map = <b>new</b> Ext.KeyMap(<em>"my-element"</em>, [
|
|
|
39 |
{
|
|
|
40 |
key: [10,13],
|
|
|
41 |
fn: <b>function</b>(){ alert(<em>"Return was pressed"</em>); }
|
|
|
42 |
}, {
|
|
|
43 |
key: <em>"abc"</em>,
|
|
|
44 |
fn: <b>function</b>(){ alert(<em>'a, b or c was pressed'</em>); }
|
|
|
45 |
}, {
|
|
|
46 |
key: <em>"\t"</em>,
|
|
|
47 |
ctrl:true,
|
|
|
48 |
shift:true,
|
|
|
49 |
fn: <b>function</b>(){ alert(<em>'Control + shift + tab was pressed.'</em>); }
|
|
|
50 |
}
|
|
|
51 |
]);</code></pre>
|
|
|
52 |
<b>Note: A KeyMap starts enabled</b> </div>
|
|
|
53 |
|
|
|
54 |
<div class="hr"></div>
|
|
|
55 |
<a id="Ext.KeyMap-props"></a>
|
|
|
56 |
<h2>Public Properties</h2>
|
|
|
57 |
<table cellspacing="0" class="member-table">
|
|
|
58 |
<tr>
|
|
|
59 |
<th class="sig-header" colspan="2">Property</th>
|
|
|
60 |
<th class="msource-header">Defined By</th>
|
|
|
61 |
</tr>
|
|
|
62 |
<tr class="property-row expandable">
|
|
|
63 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
64 |
<td class="sig">
|
|
|
65 |
<a id="Ext.KeyMap-stopEvent"></a>
|
|
|
66 |
<b>stopEvent</b> : Boolean <div class="mdesc">
|
|
|
67 |
<div class="short">True to stop the event from bubbling and prevent the default browser action if the
|
|
|
68 |
key was handled by the KeyMap (def...</div>
|
|
|
69 |
<div class="long">
|
|
|
70 |
True to stop the event from bubbling and prevent the default browser action if the
|
|
|
71 |
key was handled by the KeyMap (defaults to false) </div>
|
|
|
72 |
</div>
|
|
|
73 |
</td>
|
|
|
74 |
<td class="msource">KeyMap</td>
|
|
|
75 |
</tr>
|
|
|
76 |
</table>
|
|
|
77 |
<a id="Ext.KeyMap-methods"></a>
|
|
|
78 |
<h2>Public Methods</h2>
|
|
|
79 |
<table cellspacing="0" class="member-table">
|
|
|
80 |
<tr>
|
|
|
81 |
<th class="sig-header" colspan="2">Method</th>
|
|
|
82 |
<th class="msource-header">Defined By</th>
|
|
|
83 |
</tr>
|
|
|
84 |
<tr class="method-row expandable">
|
|
|
85 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
86 |
<td class="sig">
|
|
|
87 |
<a id="Ext.KeyMap-KeyMap"></a>
|
|
|
88 |
<b>KeyMap</b>( <code>Mixed el</code>, <code>Object config</code>, <span class="optional" title="Optional">[<code>String eventName</code>]</span> ) <div class="mdesc">
|
|
|
89 |
<div class="short"></div>
|
|
|
90 |
<div class="long">
|
|
|
91 |
<div class="mdetail-params">
|
|
|
92 |
<strong>Parameters:</strong>
|
|
|
93 |
<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>
|
|
|
94 |
<strong>Returns:</strong>
|
|
|
95 |
<ul>
|
|
|
96 |
<li><code></code></li>
|
|
|
97 |
</ul>
|
|
|
98 |
</div>
|
|
|
99 |
</div>
|
|
|
100 |
</div>
|
|
|
101 |
</td>
|
|
|
102 |
<td class="msource">KeyMap</td>
|
|
|
103 |
</tr>
|
|
|
104 |
<tr class="method-row alt expandable">
|
|
|
105 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
106 |
<td class="sig">
|
|
|
107 |
<a id="Ext.KeyMap-addBinding"></a>
|
|
|
108 |
<b>addBinding</b>( <code>Object/Array config</code> ) : void <div class="mdesc">
|
|
|
109 |
<div class="short">Add a new binding to this KeyMap. The following config object properties are supported:
|
|
|
110 |
Property Type ...</div>
|
|
|
111 |
<div class="long">
|
|
|
112 |
Add a new binding to this KeyMap. The following config object properties are supported:
|
|
|
113 |
<pre>Property Type Description
|
|
|
114 |
---------- --------------- ----------------------------------------------------------------------
|
|
|
115 |
key String/Array A single keycode or an array of keycodes to handle
|
|
|
116 |
shift Boolean True to handle key only when shift is pressed (defaults to false)
|
|
|
117 |
ctrl Boolean True to handle key only when ctrl is pressed (defaults to false)
|
|
|
118 |
alt Boolean True to handle key only when alt is pressed (defaults to false)
|
|
|
119 |
handler Function The function to call when KeyMap finds the expected key combination
|
|
|
120 |
fn Function Alias of handler (for backwards-compatibility)
|
|
|
121 |
scope Object The scope of the callback function</pre>
|
|
|
122 |
Usage:
|
|
|
123 |
<pre><code><i>// Create a KeyMap</i>
|
|
|
124 |
<b>var</b> map = <b>new</b> Ext.KeyMap(document, {
|
|
|
125 |
key: Ext.EventObject.ENTER,
|
|
|
126 |
fn: handleKey,
|
|
|
127 |
scope: <b>this</b>
|
|
|
128 |
});
|
|
|
129 |
|
|
|
130 |
<i>//Add a <b>new</b> binding to the existing KeyMap later</i>
|
|
|
131 |
map.addBinding({
|
|
|
132 |
key: <em>'abc'</em>,
|
|
|
133 |
shift: true,
|
|
|
134 |
fn: handleKey,
|
|
|
135 |
scope: <b>this</b>
|
|
|
136 |
});</code></pre> <div class="mdetail-params">
|
|
|
137 |
<strong>Parameters:</strong>
|
|
|
138 |
<ul><li><code>config</code> : Object/Array<div class="sub-desc">A single KeyMap config or an array of configs</div></li> </ul>
|
|
|
139 |
<strong>Returns:</strong>
|
|
|
140 |
<ul>
|
|
|
141 |
<li><code>void</code></li>
|
|
|
142 |
</ul>
|
|
|
143 |
</div>
|
|
|
144 |
</div>
|
|
|
145 |
</div>
|
|
|
146 |
</td>
|
|
|
147 |
<td class="msource">KeyMap</td>
|
|
|
148 |
</tr>
|
|
|
149 |
<tr class="method-row expandable">
|
|
|
150 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
151 |
<td class="sig">
|
|
|
152 |
<a id="Ext.KeyMap-disable"></a>
|
|
|
153 |
<b>disable</b>() : void <div class="mdesc">
|
|
|
154 |
<div class="short">Disable this KeyMap</div>
|
|
|
155 |
<div class="long">
|
|
|
156 |
Disable this KeyMap <div class="mdetail-params">
|
|
|
157 |
<strong>Parameters:</strong>
|
|
|
158 |
<ul><li>None.</li> </ul>
|
|
|
159 |
<strong>Returns:</strong>
|
|
|
160 |
<ul>
|
|
|
161 |
<li><code>void</code></li>
|
|
|
162 |
</ul>
|
|
|
163 |
</div>
|
|
|
164 |
</div>
|
|
|
165 |
</div>
|
|
|
166 |
</td>
|
|
|
167 |
<td class="msource">KeyMap</td>
|
|
|
168 |
</tr>
|
|
|
169 |
<tr class="method-row alt expandable">
|
|
|
170 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
171 |
<td class="sig">
|
|
|
172 |
<a id="Ext.KeyMap-enable"></a>
|
|
|
173 |
<b>enable</b>() : void <div class="mdesc">
|
|
|
174 |
<div class="short">Enables this KeyMap</div>
|
|
|
175 |
<div class="long">
|
|
|
176 |
Enables this KeyMap <div class="mdetail-params">
|
|
|
177 |
<strong>Parameters:</strong>
|
|
|
178 |
<ul><li>None.</li> </ul>
|
|
|
179 |
<strong>Returns:</strong>
|
|
|
180 |
<ul>
|
|
|
181 |
<li><code>void</code></li>
|
|
|
182 |
</ul>
|
|
|
183 |
</div>
|
|
|
184 |
</div>
|
|
|
185 |
</div>
|
|
|
186 |
</td>
|
|
|
187 |
<td class="msource">KeyMap</td>
|
|
|
188 |
</tr>
|
|
|
189 |
<tr class="method-row expandable">
|
|
|
190 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
191 |
<td class="sig">
|
|
|
192 |
<a id="Ext.KeyMap-isEnabled"></a>
|
|
|
193 |
<b>isEnabled</b>() : Boolean <div class="mdesc">
|
|
|
194 |
<div class="short">Returns true if this KeyMap is enabled</div>
|
|
|
195 |
<div class="long">
|
|
|
196 |
Returns true if this KeyMap is enabled <div class="mdetail-params">
|
|
|
197 |
<strong>Parameters:</strong>
|
|
|
198 |
<ul><li>None.</li> </ul>
|
|
|
199 |
<strong>Returns:</strong>
|
|
|
200 |
<ul>
|
|
|
201 |
<li><code>Boolean</code></li>
|
|
|
202 |
</ul>
|
|
|
203 |
</div>
|
|
|
204 |
</div>
|
|
|
205 |
</div>
|
|
|
206 |
</td>
|
|
|
207 |
<td class="msource">KeyMap</td>
|
|
|
208 |
</tr>
|
|
|
209 |
<tr class="method-row alt expandable">
|
|
|
210 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
211 |
<td class="sig">
|
|
|
212 |
<a id="Ext.KeyMap-on"></a>
|
|
|
213 |
<b>on</b>( <code>Number/Array/Object key</code>, <code>Function fn</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span> ) : void <div class="mdesc">
|
|
|
214 |
<div class="short">Shorthand for adding a single key listener</div>
|
|
|
215 |
<div class="long">
|
|
|
216 |
Shorthand for adding a single key listener <div class="mdetail-params">
|
|
|
217 |
<strong>Parameters:</strong>
|
|
|
218 |
<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
|
|
|
219 |
following options:
|
|
|
220 |
{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>
|
|
|
221 |
<strong>Returns:</strong>
|
|
|
222 |
<ul>
|
|
|
223 |
<li><code>void</code></li>
|
|
|
224 |
</ul>
|
|
|
225 |
</div>
|
|
|
226 |
</div>
|
|
|
227 |
</div>
|
|
|
228 |
</td>
|
|
|
229 |
<td class="msource">KeyMap</td>
|
|
|
230 |
</tr>
|
|
|
231 |
</table>
|
|
|
232 |
<a id="Ext.KeyMap-events"></a>
|
|
|
233 |
<h2>Public Events</h2>
|
|
|
234 |
<div class="no-members">This class has no public events.</div>
|
|
|
235 |
</div>
|