source:
trunk/workshop-routing-foss4g/web/ext/src/core/Element.keys.js
@
81
Revision 76, 1.8 KB checked in by djay, 13 years ago (diff) | |
---|---|
|
Line | |
---|---|
1 | /*! |
2 | * Ext JS Library 3.4.0 |
3 | * Copyright(c) 2006-2011 Sencha Inc. |
4 | * licensing@sencha.com |
5 | * http://www.sencha.com/license |
6 | */ |
7 | /** |
8 | * @class Ext.Element |
9 | */ |
10 | Ext.Element.addMethods({ |
11 | /** |
12 | * Convenience method for constructing a KeyMap |
13 | * @param {Number/Array/Object/String} key Either a string with the keys to listen for, the numeric key code, array of key codes or an object with the following options: |
14 | * <code>{key: (number or array), shift: (true/false), ctrl: (true/false), alt: (true/false)}</code> |
15 | * @param {Function} fn The function to call |
16 | * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the specified function is executed. Defaults to this Element. |
17 | * @return {Ext.KeyMap} The KeyMap created |
18 | */ |
19 | addKeyListener : function(key, fn, scope){ |
20 | var config; |
21 | if(typeof key != 'object' || Ext.isArray(key)){ |
22 | config = { |
23 | key: key, |
24 | fn: fn, |
25 | scope: scope |
26 | }; |
27 | }else{ |
28 | config = { |
29 | key : key.key, |
30 | shift : key.shift, |
31 | ctrl : key.ctrl, |
32 | alt : key.alt, |
33 | fn: fn, |
34 | scope: scope |
35 | }; |
36 | } |
37 | return new Ext.KeyMap(this, config); |
38 | }, |
39 | |
40 | /** |
41 | * Creates a KeyMap for this element |
42 | * @param {Object} config The KeyMap config. See {@link Ext.KeyMap} for more details |
43 | * @return {Ext.KeyMap} The KeyMap created |
44 | */ |
45 | addKeyMap : function(config){ |
46 | return new Ext.KeyMap(this, config); |
47 | } |
48 | }); |
49 | |
50 | //Import the newly-added Ext.Element functions into CompositeElementLite. We call this here because |
51 | //Element.keys.js is the last extra Ext.Element include in the ext-all.js build |
52 | Ext.CompositeElementLite.importElementMethods(); |
Note: See TracBrowser
for help on using the repository browser.