2 * Ext JS Library 2.2.1
\r
3 * Copyright(c) 2006-2009, Ext JS, LLC.
\r
4 * licensing@extjs.com
\r
6 * http://extjs.com/license
\r
10 * @class Ext.EventManager
\r
11 * Registers event handlers that want to receive a normalized EventObject instead of the standard browser event and provides
\r
12 * several useful events directly.
\r
13 * See {@link Ext.EventObject} for more details on normalized event objects.
\r
16 Ext.EventManager = function(){
\r
17 var docReadyEvent, docReadyProcId, docReadyState = false;
\r
18 var resizeEvent, resizeTask, textEvent, textSize;
\r
19 var E = Ext.lib.Event;
\r
20 var D = Ext.lib.Dom;
\r
21 // fix parser confusion
\r
22 var xname = 'Ex' + 't';
\r
26 var addListener = function(el, ename, fn, wrap, scope){
\r
27 var id = Ext.id(el);
\r
31 var es = elHash[id];
\r
44 E.on(el, ename, wrap);
\r
46 if(ename == "mousewheel" && el.addEventListener){ // workaround for jQuery
\r
47 el.addEventListener("DOMMouseScroll", wrap, false);
\r
48 E.on(window, 'unload', function(){
\r
49 el.removeEventListener("DOMMouseScroll", wrap, false);
\r
52 if(ename == "mousedown" && el == document){ // fix stopped mousedowns on the document
\r
53 Ext.EventManager.stoppedMouseDownEvent.addListener(wrap);
\r
57 var removeListener = function(el, ename, fn, scope){
\r
58 el = Ext.getDom(el);
\r
60 var id = Ext.id(el), es = elHash[id], wrap;
\r
62 var ls = es[ename], l;
\r
64 for(var i = 0, len = ls.length; i < len; i++){
\r
66 if(l.fn == fn && (!scope || l.scope == scope)){
\r
68 E.un(el, ename, wrap);
\r
75 if(ename == "mousewheel" && el.addEventListener && wrap){
\r
76 el.removeEventListener("DOMMouseScroll", wrap, false);
\r
78 if(ename == "mousedown" && el == document && wrap){ // fix stopped mousedowns on the document
\r
79 Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
\r
83 var removeAll = function(el){
\r
84 el = Ext.getDom(el);
\r
85 var id = Ext.id(el), es = elHash[id], ls;
\r
87 for(var ename in es){
\r
88 if(es.hasOwnProperty(ename)){
\r
90 for(var i = 0, len = ls.length; i < len; i++){
\r
91 E.un(el, ename, ls[i].wrap);
\r
102 var fireDocReady = function(){
\r
103 if(!docReadyState){
\r
104 docReadyState = true;
\r
105 Ext.isReady = true;
\r
106 if(docReadyProcId){
\r
107 clearInterval(docReadyProcId);
\r
109 if(Ext.isGecko || Ext.isOpera) {
\r
110 document.removeEventListener("DOMContentLoaded", fireDocReady, false);
\r
113 var defer = document.getElementById("ie-deferred-loader");
\r
115 defer.onreadystatechange = null;
\r
116 defer.parentNode.removeChild(defer);
\r
120 docReadyEvent.fire();
\r
121 docReadyEvent.clearListeners();
\r
126 var initDocReady = function(){
\r
127 docReadyEvent = new Ext.util.Event();
\r
128 if(Ext.isGecko || Ext.isOpera) {
\r
129 document.addEventListener("DOMContentLoaded", fireDocReady, false);
\r
130 }else if(Ext.isIE){
\r
131 document.write("<s"+'cript id="ie-deferred-loader" defer="defer" src="/'+'/:"></s'+"cript>");
\r
132 var defer = document.getElementById("ie-deferred-loader");
\r
133 defer.onreadystatechange = function(){
\r
134 if(this.readyState == "complete"){
\r
138 }else if(Ext.isSafari){
\r
139 docReadyProcId = setInterval(function(){
\r
140 var rs = document.readyState;
\r
141 if(rs == "complete") {
\r
146 // no matter what, make sure it fires on load
\r
147 E.on(window, "load", fireDocReady);
\r
150 var createBuffered = function(h, o){
\r
151 var task = new Ext.util.DelayedTask(h);
\r
152 return function(e){
\r
153 // create new event object impl so new events don't wipe out properties
\r
154 e = new Ext.EventObjectImpl(e);
\r
155 task.delay(o.buffer, h, null, [e]);
\r
159 var createSingle = function(h, el, ename, fn, scope){
\r
160 return function(e){
\r
161 Ext.EventManager.removeListener(el, ename, fn, scope);
\r
166 var createDelayed = function(h, o){
\r
167 return function(e){
\r
168 // create new event object impl so new events don't wipe out properties
\r
169 e = new Ext.EventObjectImpl(e);
\r
170 setTimeout(function(){
\r
176 var listen = function(element, ename, opt, fn, scope){
\r
177 var o = (!opt || typeof opt == "boolean") ? {} : opt;
\r
178 fn = fn || o.fn; scope = scope || o.scope;
\r
179 var el = Ext.getDom(element);
\r
181 throw "Error listening for \"" + ename + '\". Element "' + element + '" doesn\'t exist.';
\r
183 var h = function(e){
\r
184 // prevent errors while unload occurring
\r
185 if(!window[xname]){
\r
188 e = Ext.EventObject.setEvent(e);
\r
191 t = e.getTarget(o.delegate, el);
\r
198 if(o.stopEvent === true){
\r
201 if(o.preventDefault === true){
\r
202 e.preventDefault();
\r
204 if(o.stopPropagation === true){
\r
205 e.stopPropagation();
\r
208 if(o.normalized === false){
\r
209 e = e.browserEvent;
\r
212 fn.call(scope || el, e, t, o);
\r
215 h = createDelayed(h, o);
\r
218 h = createSingle(h, el, ename, fn, scope);
\r
221 h = createBuffered(h, o);
\r
224 addListener(el, ename, fn, h, scope);
\r
228 var propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/;
\r
232 * Appends an event handler to an element. The shorthand version {@link #on} is equivalent. Typically you will
\r
233 * use {@link Ext.Element#addListener} directly on an Element in favor of calling this version.
\r
234 * @param {String/HTMLElement} el The html element or id to assign the event handler to
\r
235 * @param {String} eventName The type of event to listen for
\r
236 * @param {Function} handler The handler function the event invokes This function is passed
\r
237 * the following parameters:<ul>
\r
238 * <li>evt : EventObject<div class="sub-desc">The {@link Ext.EventObject EventObject} describing the event.</div></li>
\r
239 * <li>t : Element<div class="sub-desc">The {@link Ext.Element Element} which was the target of the event.
\r
240 * Note that this may be filtered by using the <tt>delegate</tt> option.</div></li>
\r
241 * <li>o : Object<div class="sub-desc">The options object from the addListener call.</div></li>
\r
243 * @param {Object} scope (optional) The scope in which to execute the handler
\r
244 * function (the handler function's "this" context)
\r
245 * @param {Object} options (optional) An object containing handler configuration properties.
\r
246 * This may contain any of the following properties:<ul>
\r
247 * <li>scope {Object} : The scope in which to execute the handler function. The handler function's "this" context.</li>
\r
248 * <li>delegate {String} : A simple selector to filter the target or look for a descendant of the target</li>
\r
249 * <li>stopEvent {Boolean} : True to stop the event. That is stop propagation, and prevent the default action.</li>
\r
250 * <li>preventDefault {Boolean} : True to prevent the default action</li>
\r
251 * <li>stopPropagation {Boolean} : True to prevent event propagation</li>
\r
252 * <li>normalized {Boolean} : False to pass a browser event to the handler function instead of an Ext.EventObject</li>
\r
253 * <li>delay {Number} : The number of milliseconds to delay the invocation of the handler after te event fires.</li>
\r
254 * <li>single {Boolean} : True to add a handler to handle just the next firing of the event, and then remove itself.</li>
\r
255 * <li>buffer {Number} : Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
\r
256 * by the specified number of milliseconds. If the event fires again within that time, the original
\r
257 * handler is <em>not</em> invoked, but the new handler is scheduled in its place.</li>
\r
259 * <p>See {@link Ext.Element#addListener} for examples of how to use these options.</p>
\r
261 addListener : function(element, eventName, fn, scope, options){
\r
262 if(typeof eventName == "object"){
\r
265 if(propRe.test(e)){
\r
268 if(typeof o[e] == "function"){
\r
270 listen(element, e, o, o[e], o.scope);
\r
272 // individual options
\r
273 listen(element, e, o[e]);
\r
278 return listen(element, eventName, options, fn, scope);
\r
282 * Removes an event handler from an element. The shorthand version {@link #un} is equivalent. Typically
\r
283 * you will use {@link Ext.Element#removeListener} directly on an Element in favor of calling this version.
\r
284 * @param {String/HTMLElement} el The id or html element from which to remove the event
\r
285 * @param {String} eventName The type of event
\r
286 * @param {Function} fn The handler function to remove
\r
288 removeListener : function(element, eventName, fn, scope){
\r
289 return removeListener(element, eventName, fn, scope);
\r
293 * Removes all event handers from an element. Typically you will use {@link Ext.Element#removeAllListeners}
\r
294 * directly on an Element in favor of calling this version.
\r
295 * @param {String/HTMLElement} el The id or html element from which to remove the event
\r
297 removeAll : function(element){
\r
298 return removeAll(element);
\r
302 * Fires when the document is ready (before onload and before images are loaded). Can be
\r
303 * accessed shorthanded as Ext.onReady().
\r
304 * @param {Function} fn The method the event invokes
\r
305 * @param {Object} scope (optional) An object that becomes the scope of the handler
\r
306 * @param {boolean} options (optional) An object containing standard {@link #addListener} options
\r
308 onDocumentReady : function(fn, scope, options){
\r
309 if(docReadyState){ // if it already fired
\r
310 docReadyEvent.addListener(fn, scope, options);
\r
311 docReadyEvent.fire();
\r
312 docReadyEvent.clearListeners();
\r
315 if(!docReadyEvent){
\r
318 options = options || {};
\r
319 if(!options.delay){
\r
322 docReadyEvent.addListener(fn, scope, options);
\r
326 doResizeEvent: function(){
\r
327 resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
\r
331 * Fires when the window is resized and provides resize event buffering (50 milliseconds), passes new viewport width and height to handlers.
\r
332 * @param {Function} fn The method the event invokes
\r
333 * @param {Object} scope An object that becomes the scope of the handler
\r
334 * @param {boolean} options
\r
336 onWindowResize : function(fn, scope, options){
\r
338 resizeEvent = new Ext.util.Event();
\r
339 resizeTask = new Ext.util.DelayedTask(this.doResizeEvent);
\r
340 E.on(window, "resize", this.fireWindowResize, this);
\r
342 resizeEvent.addListener(fn, scope, options);
\r
345 // exposed only to allow manual firing
\r
346 fireWindowResize : function(){
\r
348 if((Ext.isIE||Ext.isAir) && resizeTask){
\r
349 resizeTask.delay(50);
\r
351 resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
\r
357 * Fires when the user changes the active text size. Handler gets called with 2 params, the old size and the new size.
\r
358 * @param {Function} fn The method the event invokes
\r
359 * @param {Object} scope An object that becomes the scope of the handler
\r
360 * @param {boolean} options
\r
362 onTextResize : function(fn, scope, options){
\r
364 textEvent = new Ext.util.Event();
\r
365 var textEl = new Ext.Element(document.createElement('div'));
\r
366 textEl.dom.className = 'x-text-resize';
\r
367 textEl.dom.innerHTML = 'X';
\r
368 textEl.appendTo(document.body);
\r
369 textSize = textEl.dom.offsetHeight;
\r
370 setInterval(function(){
\r
371 if(textEl.dom.offsetHeight != textSize){
\r
372 textEvent.fire(textSize, textSize = textEl.dom.offsetHeight);
\r
374 }, this.textResizeInterval);
\r
376 textEvent.addListener(fn, scope, options);
\r
380 * Removes the passed window resize listener.
\r
381 * @param {Function} fn The method the event invokes
\r
382 * @param {Object} scope The scope of handler
\r
384 removeResizeListener : function(fn, scope){
\r
386 resizeEvent.removeListener(fn, scope);
\r
391 fireResize : function(){
\r
393 resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
\r
397 * Url used for onDocumentReady with using SSL (defaults to Ext.SSL_SECURE_URL)
\r
399 ieDeferSrc : false,
\r
401 * The frequency, in milliseconds, to check for text resize events (defaults to 50)
\r
403 textResizeInterval : 50
\r
406 * Appends an event handler to an element. Shorthand for {@link #addListener}.
\r
407 * @param {String/HTMLElement} el The html element or id to assign the event handler to
\r
408 * @param {String} eventName The type of event to listen for
\r
409 * @param {Function} handler The handler function the event invokes
\r
410 * @param {Object} scope (optional) The scope in which to execute the handler
\r
411 * function (the handler function's "this" context)
\r
412 * @param {Object} options (optional) An object containing standard {@link #addListener} options
\r
413 * @member Ext.EventManager
\r
416 pub.on = pub.addListener;
\r
418 * Removes an event handler from an element. Shorthand for {@link #removeListener}.
\r
419 * @param {String/HTMLElement} el The id or html element from which to remove the event
\r
420 * @param {String} eventName The type of event
\r
421 * @param {Function} fn The handler function to remove
\r
422 * @return {Boolean} True if a listener was actually removed, else false
\r
423 * @member Ext.EventManager
\r
426 pub.un = pub.removeListener;
\r
428 pub.stoppedMouseDownEvent = new Ext.util.Event();
\r
432 * Fires when the document is ready (before onload and before images are loaded). Shorthand of {@link Ext.EventManager#onDocumentReady}.
\r
433 * @param {Function} fn The method the event invokes
\r
434 * @param {Object} scope An object that becomes the scope of the handler
\r
435 * @param {boolean} options (optional) An object containing standard {@link #addListener} options
\r
439 Ext.onReady = Ext.EventManager.onDocumentReady;
\r
442 // Initialize doc classes
\r
444 var initExtCss = function(){
\r
445 // find the body element
\r
446 var bd = document.body || document.getElementsByTagName('body')[0];
\r
447 if(!bd){ return false; }
\r
449 Ext.isIE ? "ext-ie " + (Ext.isIE6 ? 'ext-ie6' : (Ext.isIE7 ? 'ext-ie7' : 'ext-ie8'))
\r
450 : Ext.isGecko ? "ext-gecko " + (Ext.isGecko2 ? 'ext-gecko2' : 'ext-gecko3')
\r
451 : Ext.isOpera ? "ext-opera"
\r
452 : Ext.isSafari ? "ext-safari"
\r
453 : Ext.isChrome ? "ext-chrome" : ""];
\r
456 cls.push("ext-mac");
\r
459 cls.push("ext-linux");
\r
461 if(Ext.isBorderBox){
\r
462 cls.push('ext-border-box');
\r
464 if(Ext.isStrict){ // add to the parent to allow for selectors like ".ext-strict .ext-ie"
\r
465 var p = bd.parentNode;
\r
467 p.className += ' ext-strict';
\r
470 bd.className += cls.join(' ');
\r
475 Ext.onReady(initExtCss);
\r
480 * @class Ext.EventObject
\r
481 * EventObject exposes the Yahoo! UI Event functionality directly on the object
\r
482 * passed to your event handler. It exists mostly for convenience. It also fixes the annoying null checks automatically to cleanup your code
\r
485 function handleClick(e){ // e is not a standard event object, it is a Ext.EventObject
\r
486 e.preventDefault();
\r
487 var target = e.getTarget();
\r
490 var myDiv = Ext.get("myDiv");
\r
491 myDiv.on("click", handleClick);
\r
493 Ext.EventManager.on("myDiv", 'click', handleClick);
\r
494 Ext.EventManager.addListener("myDiv", 'click', handleClick);
\r
498 Ext.EventObject = function(){
\r
500 var E = Ext.lib.Event;
\r
502 // safari keypress events for special keys return bad keycodes
\r
505 63234 : 37, // left
\r
506 63235 : 39, // right
\r
508 63233 : 40, // down
\r
509 63276 : 33, // page up
\r
510 63277 : 34, // page down
\r
511 63272 : 46, // delete
\r
512 63273 : 36, // home
\r
516 // normalize button clicks
\r
517 var btnMap = Ext.isIE ? {1:0,4:1,2:2} :
\r
518 (Ext.isSafari ? {1:0,2:1,3:2} : {0:0,1:1,2:2});
\r
520 Ext.EventObjectImpl = function(e){
\r
522 this.setEvent(e.browserEvent || e);
\r
526 Ext.EventObjectImpl.prototype = {
\r
527 /** The normal browser event */
\r
528 browserEvent : null,
\r
529 /** The button pressed in a mouse event */
\r
531 /** True if the shift key was down during the event */
\r
533 /** True if the control key was down during the event */
\r
535 /** True if the alt key was down during the event */
\r
538 /** Key constant @type Number */
\r
540 /** Key constant @type Number */
\r
542 /** Key constant @type Number */
\r
544 /** Key constant @type Number */
\r
546 /** Key constant @type Number */
\r
548 /** Key constant @type Number */
\r
550 /** Key constant @type Number */
\r
552 CONTROL : 17, // legacy
\r
553 /** Key constant @type Number */
\r
555 /** Key constant @type Number */
\r
557 /** Key constant @type Number */
\r
559 /** Key constant @type Number */
\r
561 /** Key constant @type Number */
\r
563 /** Key constant @type Number */
\r
565 PAGEUP : 33, // legacy
\r
566 /** Key constant @type Number */
\r
568 PAGEDOWN : 34, // legacy
\r
569 /** Key constant @type Number */
\r
571 /** Key constant @type Number */
\r
573 /** Key constant @type Number */
\r
575 /** Key constant @type Number */
\r
577 /** Key constant @type Number */
\r
579 /** Key constant @type Number */
\r
581 /** Key constant @type Number */
\r
583 /** Key constant @type Number */
\r
585 /** Key constant @type Number */
\r
587 /** Key constant @type Number */
\r
589 /** Key constant @type Number */
\r
591 /** Key constant @type Number */
\r
593 /** Key constant @type Number */
\r
595 /** Key constant @type Number */
\r
597 /** Key constant @type Number */
\r
599 /** Key constant @type Number */
\r
601 /** Key constant @type Number */
\r
603 /** Key constant @type Number */
\r
605 /** Key constant @type Number */
\r
607 /** Key constant @type Number */
\r
609 /** Key constant @type Number */
\r
611 /** Key constant @type Number */
\r
613 /** Key constant @type Number */
\r
615 /** Key constant @type Number */
\r
617 /** Key constant @type Number */
\r
619 /** Key constant @type Number */
\r
621 /** Key constant @type Number */
\r
623 /** Key constant @type Number */
\r
625 /** Key constant @type Number */
\r
627 /** Key constant @type Number */
\r
629 /** Key constant @type Number */
\r
631 /** Key constant @type Number */
\r
633 /** Key constant @type Number */
\r
635 /** Key constant @type Number */
\r
637 /** Key constant @type Number */
\r
639 /** Key constant @type Number */
\r
641 /** Key constant @type Number */
\r
643 /** Key constant @type Number */
\r
645 /** Key constant @type Number */
\r
647 /** Key constant @type Number */
\r
649 /** Key constant @type Number */
\r
651 /** Key constant @type Number */
\r
653 /** Key constant @type Number */
\r
655 /** Key constant @type Number */
\r
657 /** Key constant @type Number */
\r
659 /** Key constant @type Number */
\r
661 /** Key constant @type Number */
\r
663 /** Key constant @type Number */
\r
665 /** Key constant @type Number */
\r
667 /** Key constant @type Number */
\r
669 /** Key constant @type Number */
\r
671 /** Key constant @type Number */
\r
673 /** Key constant @type Number */
\r
675 /** Key constant @type Number */
\r
677 /** Key constant @type Number */
\r
679 /** Key constant @type Number */
\r
681 /** Key constant @type Number */
\r
683 /** Key constant @type Number */
\r
685 /** Key constant @type Number */
\r
687 /** Key constant @type Number */
\r
689 /** Key constant @type Number */
\r
691 /** Key constant @type Number */
\r
693 /** Key constant @type Number */
\r
695 /** Key constant @type Number */
\r
697 /** Key constant @type Number */
\r
699 /** Key constant @type Number */
\r
701 /** Key constant @type Number */
\r
703 /** Key constant @type Number */
\r
705 /** Key constant @type Number */
\r
707 /** Key constant @type Number */
\r
709 /** Key constant @type Number */
\r
711 /** Key constant @type Number */
\r
713 /** Key constant @type Number */
\r
717 setEvent : function(e){
\r
718 if(e == this || (e && e.browserEvent)){ // already wrapped
\r
721 this.browserEvent = e;
\r
723 // normalize buttons
\r
724 this.button = e.button ? btnMap[e.button] : (e.which ? e.which-1 : -1);
\r
725 if(e.type == 'click' && this.button == -1){
\r
728 this.type = e.type;
\r
729 this.shiftKey = e.shiftKey;
\r
730 // mac metaKey behaves like ctrlKey
\r
731 this.ctrlKey = e.ctrlKey || e.metaKey;
\r
732 this.altKey = e.altKey;
\r
733 // in getKey these will be normalized for the mac
\r
734 this.keyCode = e.keyCode;
\r
735 this.charCode = e.charCode;
\r
736 // cache the target for the delayed and or buffered events
\r
737 this.target = E.getTarget(e);
\r
739 this.xy = E.getXY(e);
\r
742 this.shiftKey = false;
\r
743 this.ctrlKey = false;
\r
744 this.altKey = false;
\r
747 this.target = null;
\r
754 * Stop the event (preventDefault and stopPropagation)
\r
756 stopEvent : function(){
\r
757 if(this.browserEvent){
\r
758 if(this.browserEvent.type == 'mousedown'){
\r
759 Ext.EventManager.stoppedMouseDownEvent.fire(this);
\r
761 E.stopEvent(this.browserEvent);
\r
766 * Prevents the browsers default handling of the event.
\r
768 preventDefault : function(){
\r
769 if(this.browserEvent){
\r
770 E.preventDefault(this.browserEvent);
\r
775 isNavKeyPress : function(){
\r
776 var k = this.keyCode;
\r
777 k = Ext.isSafari ? (safariKeys[k] || k) : k;
\r
778 return (k >= 33 && k <= 40) || k == this.RETURN || k == this.TAB || k == this.ESC;
\r
781 isSpecialKey : function(){
\r
782 var k = this.keyCode;
\r
783 return (this.type == 'keypress' && this.ctrlKey) || k == 9 || k == 13 || k == 40 || k == 27 ||
\r
784 (k == 16) || (k == 17) ||
\r
785 (k >= 18 && k <= 20) ||
\r
786 (k >= 33 && k <= 35) ||
\r
787 (k >= 36 && k <= 39) ||
\r
788 (k >= 44 && k <= 45);
\r
792 * Cancels bubbling of the event.
\r
794 stopPropagation : function(){
\r
795 if(this.browserEvent){
\r
796 if(this.browserEvent.type == 'mousedown'){
\r
797 Ext.EventManager.stoppedMouseDownEvent.fire(this);
\r
799 E.stopPropagation(this.browserEvent);
\r
804 * Gets the character code for the event.
\r
807 getCharCode : function(){
\r
808 return this.charCode || this.keyCode;
\r
812 * Returns a normalized keyCode for the event.
\r
813 * @return {Number} The key code
\r
815 getKey : function(){
\r
816 var k = this.keyCode || this.charCode;
\r
817 return Ext.isSafari ? (safariKeys[k] || k) : k;
\r
821 * Gets the x coordinate of the event.
\r
824 getPageX : function(){
\r
829 * Gets the y coordinate of the event.
\r
832 getPageY : function(){
\r
837 * Gets the time of the event.
\r
840 getTime : function(){
\r
841 if(this.browserEvent){
\r
842 return E.getTime(this.browserEvent);
\r
848 * Gets the page coordinates of the event.
\r
849 * @return {Array} The xy values like [x, y]
\r
851 getXY : function(){
\r
856 * Gets the target for the event.
\r
857 * @param {String} selector (optional) A simple selector to filter the target or look for an ancestor of the target
\r
858 * @param {Number/Mixed} maxDepth (optional) The max depth to
\r
859 search as a number or element (defaults to 10 || document.body)
\r
860 * @param {Boolean} returnEl (optional) True to return a Ext.Element object instead of DOM node
\r
861 * @return {HTMLelement}
\r
863 getTarget : function(selector, maxDepth, returnEl){
\r
864 return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
\r
868 * Gets the related target.
\r
869 * @return {HTMLElement}
\r
871 getRelatedTarget : function(){
\r
872 if(this.browserEvent){
\r
873 return E.getRelatedTarget(this.browserEvent);
\r
879 * Normalizes mouse wheel delta across browsers
\r
880 * @return {Number} The delta
\r
882 getWheelDelta : function(){
\r
883 var e = this.browserEvent;
\r
885 if(e.wheelDelta){ /* IE/Opera. */
\r
886 delta = e.wheelDelta/120;
\r
887 }else if(e.detail){ /* Mozilla case. */
\r
888 delta = -e.detail/3;
\r
894 * Returns true if the control, meta, shift or alt key was pressed during this event.
\r
895 * @return {Boolean}
\r
897 hasModifier : function(){
\r
898 return ((this.ctrlKey || this.altKey) || this.shiftKey) ? true : false;
\r
902 * Returns true if the target of this event is a child of el. Unless the allowEl parameter is set, it will return false if if the target is el.
\r
903 * Example usage:<pre><code>
\r
904 // Handle click on any child of an element
\r
905 Ext.getBody().on('click', function(e){
\r
906 if(e.within('some-el')){
\r
907 alert('Clicked on a child of some-el!');
\r
911 // Handle click directly on an element, ignoring clicks on child nodes
\r
912 Ext.getBody().on('click', function(e,t){
\r
913 if((t.id == 'some-el') && !e.within(t, true)){
\r
914 alert('Clicked directly on some-el!');
\r
918 * @param {Mixed} el The id, DOM element or Ext.Element to check
\r
919 * @param {Boolean} related (optional) true to test if the related target is within el instead of the target
\r
920 * @param {Boolean} allowEl {optional} true to also check if the passed element is the target or related target
\r
921 * @return {Boolean}
\r
923 within : function(el, related, allowEl){
\r
924 var t = this[related ? "getRelatedTarget" : "getTarget"]();
\r
925 return t && ((allowEl ? (t === Ext.getDom(el)) : false) || Ext.fly(el).contains(t));
\r
928 getPoint : function(){
\r
929 return new Ext.lib.Point(this.xy[0], this.xy[1]);
\r
933 return new Ext.EventObjectImpl();
\r