Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / docs / source / Element.keys.html
index 8e4a9d5..3e3a3cf 100644 (file)
@@ -1 +1,66 @@
-<!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre></pre></pre></body></html>
\ No newline at end of file
+<!DOCTYPE html>
+<html>
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  <title>The source code</title>
+  <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
+  <script type="text/javascript" src="../prettify/prettify.js"></script>
+  <style type="text/css">
+    .highlight { display: block; background-color: #ddd; }
+  </style>
+  <script type="text/javascript">
+    function highlight() {
+      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
+    }
+  </script>
+</head>
+<body onload="prettyPrint(); highlight();">
+  <pre class="prettyprint lang-js"><span id='Ext-core-Element'>/**
+</span> * @class Ext.core.Element
+ */
+Ext.core.Element.addMethods({
+<span id='Ext-core-Element-method-addKeyListener'>    /**
+</span>     * Convenience method for constructing a KeyMap
+     * @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:
+     * &lt;code&gt;{key: (number or array), shift: (true/false), ctrl: (true/false), alt: (true/false)}&lt;/code&gt;
+     * @param {Function} fn The function to call
+     * @param {Object} scope (optional) The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the specified function is executed. Defaults to this Element.
+     * @return {Ext.util.KeyMap} The KeyMap created
+     */
+    addKeyListener : function(key, fn, scope){
+        var config;
+        if(typeof key != 'object' || Ext.isArray(key)){
+            config = {
+                key: key,
+                fn: fn,
+                scope: scope
+            };
+        }else{
+            config = {
+                key : key.key,
+                shift : key.shift,
+                ctrl : key.ctrl,
+                alt : key.alt,
+                fn: fn,
+                scope: scope
+            };
+        }
+        return Ext.create('Ext.util.KeyMap', this, config);
+    },
+
+<span id='Ext-core-Element-method-addKeyMap'>    /**
+</span>     * Creates a KeyMap for this element
+     * @param {Object} config The KeyMap config. See {@link Ext.util.KeyMap} for more details
+     * @return {Ext.util.KeyMap} The KeyMap created
+     */
+    addKeyMap : function(config){
+        return Ext.create('Ext.util.KeyMap', this, config);
+    }
+});
+
+//Import the newly-added Ext.core.Element functions into CompositeElementLite. We call this here because
+//Element.keys.js is the last extra Ext.core.Element include in the ext-all.js build
+Ext.CompositeElementLite.importElementMethods();
+</pre>
+</body>
+</html>