3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
16 * @class Ext.EventManager
18 Ext.apply(Ext.EventManager, function(){
24 propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
27 // note 1: IE fires ONLY the keydown event on specialkey autorepeat
28 // note 2: Safari < 3.1, Gecko (Mac/Linux) & Opera fire only the keypress event on specialkey autorepeat
29 // (research done by @Jan Wolter at http://unixpapa.com/js/key.html)
30 useKeydown = Ext.isWebKit ?
31 Ext.num(navigator.userAgent.match(/AppleWebKit\/(\d+)/)[1]) >= 525 :
32 !((Ext.isGecko && !Ext.isWindows) || Ext.isOpera);
36 doResizeEvent: function(){
37 var h = D.getViewHeight(),
40 //whacky problem in IE where the resize event will fire even though the w/h are the same.
41 if(curHeight != h || curWidth != w){
42 resizeEvent.fire(curWidth = w, curHeight = h);
46 <div id="method-Ext.EventManager-onWindowResize"></div>/**
47 * Adds a listener to be notified when the browser window is resized and provides resize event buffering (100 milliseconds),
48 * passes new viewport width and height to handlers.
49 * @param {Function} fn The handler function the window resize event invokes.
50 * @param {Object} scope The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
51 * @param {boolean} options Options object as passed to {@link Ext.Element#addListener}
53 onWindowResize : function(fn, scope, options){
55 resizeEvent = new Ext.util.Event();
56 resizeTask = new Ext.util.DelayedTask(this.doResizeEvent);
57 Ext.EventManager.on(window, "resize", this.fireWindowResize, this);
59 resizeEvent.addListener(fn, scope, options);
62 // exposed only to allow manual firing
63 fireWindowResize : function(){
65 resizeTask.delay(100);
69 <div id="method-Ext.EventManager-onTextResize"></div>/**
70 * Adds a listener to be notified when the user changes the active text size. Handler gets called with 2 params, the old size and the new size.
71 * @param {Function} fn The function the event invokes.
72 * @param {Object} scope The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
73 * @param {boolean} options Options object as passed to {@link Ext.Element#addListener}
75 onTextResize : function(fn, scope, options){
77 textEvent = new Ext.util.Event();
78 var textEl = new Ext.Element(document.createElement('div'));
79 textEl.dom.className = 'x-text-resize';
80 textEl.dom.innerHTML = 'X';
81 textEl.appendTo(document.body);
82 textSize = textEl.dom.offsetHeight;
83 setInterval(function(){
84 if(textEl.dom.offsetHeight != textSize){
85 textEvent.fire(textSize, textSize = textEl.dom.offsetHeight);
87 }, this.textResizeInterval);
89 textEvent.addListener(fn, scope, options);
92 <div id="method-Ext.EventManager-removeResizeListener"></div>/**
93 * Removes the passed window resize listener.
94 * @param {Function} fn The method the event invokes
95 * @param {Object} scope The scope of handler
97 removeResizeListener : function(fn, scope){
99 resizeEvent.removeListener(fn, scope);
104 fireResize : function(){
106 resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
110 <div id="prop-Ext.EventManager-textResizeInterval"></div>/**
111 * The frequency, in milliseconds, to check for text resize events (defaults to 50)
113 textResizeInterval : 50,
115 <div id="prop-Ext.EventManager-ieDeferSrc"></div>/**
116 * Url used for onDocumentReady with using SSL (defaults to Ext.SSL_SECURE_URL)
120 // protected, short accessor for useKeydown
121 getKeyEvent : function(){
122 return useKeydown ? 'keydown' : 'keypress';
125 // protected for use inside the framework
126 // detects whether we should use keydown or keypress based on the browser.
127 useKeydown: useKeydown
131 Ext.EventManager.on = Ext.EventManager.addListener;
134 Ext.apply(Ext.EventObjectImpl.prototype, {
135 <div id="prop-Ext.EventManager-BACKSPACE"></div>/** Key constant @type Number */
137 <div id="prop-Ext.EventManager-TAB"></div>/** Key constant @type Number */
139 <div id="prop-Ext.EventManager-NUM_CENTER"></div>/** Key constant @type Number */
141 <div id="prop-Ext.EventManager-ENTER"></div>/** Key constant @type Number */
143 <div id="prop-Ext.EventManager-RETURN"></div>/** Key constant @type Number */
145 <div id="prop-Ext.EventManager-SHIFT"></div>/** Key constant @type Number */
147 <div id="prop-Ext.EventManager-CTRL"></div>/** Key constant @type Number */
149 CONTROL : 17, // legacy
150 <div id="prop-Ext.EventManager-ALT"></div>/** Key constant @type Number */
152 <div id="prop-Ext.EventManager-PAUSE"></div>/** Key constant @type Number */
154 <div id="prop-Ext.EventManager-CAPS_LOCK"></div>/** Key constant @type Number */
156 <div id="prop-Ext.EventManager-ESC"></div>/** Key constant @type Number */
158 <div id="prop-Ext.EventManager-SPACE"></div>/** Key constant @type Number */
160 <div id="prop-Ext.EventManager-PAGE_UP"></div>/** Key constant @type Number */
162 PAGEUP : 33, // legacy
163 <div id="prop-Ext.EventManager-PAGE_DOWN"></div>/** Key constant @type Number */
165 PAGEDOWN : 34, // legacy
166 <div id="prop-Ext.EventManager-END"></div>/** Key constant @type Number */
168 <div id="prop-Ext.EventManager-HOME"></div>/** Key constant @type Number */
170 <div id="prop-Ext.EventManager-LEFT"></div>/** Key constant @type Number */
172 <div id="prop-Ext.EventManager-UP"></div>/** Key constant @type Number */
174 <div id="prop-Ext.EventManager-RIGHT"></div>/** Key constant @type Number */
176 <div id="prop-Ext.EventManager-DOWN"></div>/** Key constant @type Number */
178 <div id="prop-Ext.EventManager-PRINT_SCREEN"></div>/** Key constant @type Number */
180 <div id="prop-Ext.EventManager-INSERT"></div>/** Key constant @type Number */
182 <div id="prop-Ext.EventManager-DELETE"></div>/** Key constant @type Number */
184 <div id="prop-Ext.EventManager-ZERO"></div>/** Key constant @type Number */
186 <div id="prop-Ext.EventManager-ONE"></div>/** Key constant @type Number */
188 <div id="prop-Ext.EventManager-TWO"></div>/** Key constant @type Number */
190 <div id="prop-Ext.EventManager-THREE"></div>/** Key constant @type Number */
192 <div id="prop-Ext.EventManager-FOUR"></div>/** Key constant @type Number */
194 <div id="prop-Ext.EventManager-FIVE"></div>/** Key constant @type Number */
196 <div id="prop-Ext.EventManager-SIX"></div>/** Key constant @type Number */
198 <div id="prop-Ext.EventManager-SEVEN"></div>/** Key constant @type Number */
200 <div id="prop-Ext.EventManager-EIGHT"></div>/** Key constant @type Number */
202 <div id="prop-Ext.EventManager-NINE"></div>/** Key constant @type Number */
204 <div id="prop-Ext.EventManager-A"></div>/** Key constant @type Number */
206 <div id="prop-Ext.EventManager-B"></div>/** Key constant @type Number */
208 <div id="prop-Ext.EventManager-C"></div>/** Key constant @type Number */
210 <div id="prop-Ext.EventManager-D"></div>/** Key constant @type Number */
212 <div id="prop-Ext.EventManager-E"></div>/** Key constant @type Number */
214 <div id="prop-Ext.EventManager-F"></div>/** Key constant @type Number */
216 <div id="prop-Ext.EventManager-G"></div>/** Key constant @type Number */
218 <div id="prop-Ext.EventManager-H"></div>/** Key constant @type Number */
220 <div id="prop-Ext.EventManager-I"></div>/** Key constant @type Number */
222 <div id="prop-Ext.EventManager-J"></div>/** Key constant @type Number */
224 <div id="prop-Ext.EventManager-K"></div>/** Key constant @type Number */
226 <div id="prop-Ext.EventManager-L"></div>/** Key constant @type Number */
228 <div id="prop-Ext.EventManager-M"></div>/** Key constant @type Number */
230 <div id="prop-Ext.EventManager-N"></div>/** Key constant @type Number */
232 <div id="prop-Ext.EventManager-O"></div>/** Key constant @type Number */
234 <div id="prop-Ext.EventManager-P"></div>/** Key constant @type Number */
236 <div id="prop-Ext.EventManager-Q"></div>/** Key constant @type Number */
238 <div id="prop-Ext.EventManager-R"></div>/** Key constant @type Number */
240 <div id="prop-Ext.EventManager-S"></div>/** Key constant @type Number */
242 <div id="prop-Ext.EventManager-T"></div>/** Key constant @type Number */
244 <div id="prop-Ext.EventManager-U"></div>/** Key constant @type Number */
246 <div id="prop-Ext.EventManager-V"></div>/** Key constant @type Number */
248 <div id="prop-Ext.EventManager-W"></div>/** Key constant @type Number */
250 <div id="prop-Ext.EventManager-X"></div>/** Key constant @type Number */
252 <div id="prop-Ext.EventManager-Y"></div>/** Key constant @type Number */
254 <div id="prop-Ext.EventManager-Z"></div>/** Key constant @type Number */
256 <div id="prop-Ext.EventManager-CONTEXT_MENU"></div>/** Key constant @type Number */
258 <div id="prop-Ext.EventManager-NUM_ZERO"></div>/** Key constant @type Number */
260 <div id="prop-Ext.EventManager-NUM_ONE"></div>/** Key constant @type Number */
262 <div id="prop-Ext.EventManager-NUM_TWO"></div>/** Key constant @type Number */
264 <div id="prop-Ext.EventManager-NUM_THREE"></div>/** Key constant @type Number */
266 <div id="prop-Ext.EventManager-NUM_FOUR"></div>/** Key constant @type Number */
268 <div id="prop-Ext.EventManager-NUM_FIVE"></div>/** Key constant @type Number */
270 <div id="prop-Ext.EventManager-NUM_SIX"></div>/** Key constant @type Number */
272 <div id="prop-Ext.EventManager-NUM_SEVEN"></div>/** Key constant @type Number */
274 <div id="prop-Ext.EventManager-NUM_EIGHT"></div>/** Key constant @type Number */
276 <div id="prop-Ext.EventManager-NUM_NINE"></div>/** Key constant @type Number */
278 <div id="prop-Ext.EventManager-NUM_MULTIPLY"></div>/** Key constant @type Number */
280 <div id="prop-Ext.EventManager-NUM_PLUS"></div>/** Key constant @type Number */
282 <div id="prop-Ext.EventManager-NUM_MINUS"></div>/** Key constant @type Number */
284 <div id="prop-Ext.EventManager-NUM_PERIOD"></div>/** Key constant @type Number */
286 <div id="prop-Ext.EventManager-NUM_DIVISION"></div>/** Key constant @type Number */
288 <div id="prop-Ext.EventManager-F1"></div>/** Key constant @type Number */
290 <div id="prop-Ext.EventManager-F2"></div>/** Key constant @type Number */
292 <div id="prop-Ext.EventManager-F3"></div>/** Key constant @type Number */
294 <div id="prop-Ext.EventManager-F4"></div>/** Key constant @type Number */
296 <div id="prop-Ext.EventManager-F5"></div>/** Key constant @type Number */
298 <div id="prop-Ext.EventManager-F6"></div>/** Key constant @type Number */
300 <div id="prop-Ext.EventManager-F7"></div>/** Key constant @type Number */
302 <div id="prop-Ext.EventManager-F8"></div>/** Key constant @type Number */
304 <div id="prop-Ext.EventManager-F9"></div>/** Key constant @type Number */
306 <div id="prop-Ext.EventManager-F10"></div>/** Key constant @type Number */
308 <div id="prop-Ext.EventManager-F11"></div>/** Key constant @type Number */
310 <div id="prop-Ext.EventManager-F12"></div>/** Key constant @type Number */
314 isNavKeyPress : function(){
316 k = this.normalizeKey(me.keyCode);
317 return (k >= 33 && k <= 40) || // Page Up/Down, End, Home, Left, Up, Right, Down
323 isSpecialKey : function(){
324 var k = this.normalizeKey(this.keyCode);
325 return (this.type == 'keypress' && this.ctrlKey) ||
326 this.isNavKeyPress() ||
327 (k == this.BACKSPACE) || // Backspace
328 (k >= 16 && k <= 20) || // Shift, Ctrl, Alt, Pause, Caps Lock
329 (k >= 44 && k <= 46); // Print Screen, Insert, Delete
332 getPoint : function(){
333 return new Ext.lib.Point(this.xy[0], this.xy[1]);
336 <div id="method-Ext.EventManager-hasModifier"></div>/**
337 * Returns true if the control, meta, shift or alt key was pressed during this event.
340 hasModifier : function(){
341 return ((this.ctrlKey || this.altKey) || this.shiftKey);