4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-EventObject'>/**
19 </span> * @class Ext.EventObject
21 Just as {@link Ext.core.Element} wraps around a native DOM node, Ext.EventObject
22 wraps the browser's native event-object normalizing cross-browser differences,
23 such as which mouse button is clicked, keys pressed, mechanisms to stop
24 event-propagation along with a method to prevent default actions from taking place.
28 function handleClick(e, t){ // e is not a standard event object, it is a Ext.EventObject
30 var target = e.getTarget(); // same as t (the target HTMLElement)
34 var myDiv = {@link Ext#get Ext.get}("myDiv"); // get reference to an {@link Ext.core.Element}
35 myDiv.on( // 'on' is shorthand for addListener
36 "click", // perform an action on click of myDiv
37 handleClick // reference to the action handler
40 // other methods to do the same:
41 Ext.EventManager.on("myDiv", 'click', handleClick);
42 Ext.EventManager.addListener("myDiv", 'click', handleClick);
47 Ext.define('Ext.EventObjectImpl', {
48 uses: ['Ext.util.Point'],
50 <span id='Ext-EventObject-property-BACKSPACE'> /** Key constant @type Number */
52 <span id='Ext-EventObject-property-TAB'> /** Key constant @type Number */
54 <span id='Ext-EventObject-property-NUM_CENTER'> /** Key constant @type Number */
55 </span> NUM_CENTER: 12,
56 <span id='Ext-EventObject-property-ENTER'> /** Key constant @type Number */
58 <span id='Ext-EventObject-property-RETURN'> /** Key constant @type Number */
60 <span id='Ext-EventObject-property-SHIFT'> /** Key constant @type Number */
62 <span id='Ext-EventObject-property-CTRL'> /** Key constant @type Number */
64 <span id='Ext-EventObject-property-ALT'> /** Key constant @type Number */
66 <span id='Ext-EventObject-property-PAUSE'> /** Key constant @type Number */
68 <span id='Ext-EventObject-property-CAPS_LOCK'> /** Key constant @type Number */
69 </span> CAPS_LOCK: 20,
70 <span id='Ext-EventObject-property-ESC'> /** Key constant @type Number */
72 <span id='Ext-EventObject-property-SPACE'> /** Key constant @type Number */
74 <span id='Ext-EventObject-property-PAGE_UP'> /** Key constant @type Number */
76 <span id='Ext-EventObject-property-PAGE_DOWN'> /** Key constant @type Number */
77 </span> PAGE_DOWN: 34,
78 <span id='Ext-EventObject-property-END'> /** Key constant @type Number */
80 <span id='Ext-EventObject-property-HOME'> /** Key constant @type Number */
82 <span id='Ext-EventObject-property-LEFT'> /** Key constant @type Number */
84 <span id='Ext-EventObject-property-UP'> /** Key constant @type Number */
86 <span id='Ext-EventObject-property-RIGHT'> /** Key constant @type Number */
88 <span id='Ext-EventObject-property-DOWN'> /** Key constant @type Number */
90 <span id='Ext-EventObject-property-PRINT_SCREEN'> /** Key constant @type Number */
91 </span> PRINT_SCREEN: 44,
92 <span id='Ext-EventObject-property-INSERT'> /** Key constant @type Number */
94 <span id='Ext-EventObject-property-DELETE'> /** Key constant @type Number */
96 <span id='Ext-EventObject-property-ZERO'> /** Key constant @type Number */
98 <span id='Ext-EventObject-property-ONE'> /** Key constant @type Number */
100 <span id='Ext-EventObject-property-TWO'> /** Key constant @type Number */
102 <span id='Ext-EventObject-property-THREE'> /** Key constant @type Number */
104 <span id='Ext-EventObject-property-FOUR'> /** Key constant @type Number */
106 <span id='Ext-EventObject-property-FIVE'> /** Key constant @type Number */
108 <span id='Ext-EventObject-property-SIX'> /** Key constant @type Number */
110 <span id='Ext-EventObject-property-SEVEN'> /** Key constant @type Number */
112 <span id='Ext-EventObject-property-EIGHT'> /** Key constant @type Number */
114 <span id='Ext-EventObject-property-NINE'> /** Key constant @type Number */
116 <span id='Ext-EventObject-property-A'> /** Key constant @type Number */
118 <span id='Ext-EventObject-property-B'> /** Key constant @type Number */
120 <span id='Ext-EventObject-property-C'> /** Key constant @type Number */
122 <span id='Ext-EventObject-property-D'> /** Key constant @type Number */
124 <span id='Ext-EventObject-property-E'> /** Key constant @type Number */
126 <span id='Ext-EventObject-property-F'> /** Key constant @type Number */
128 <span id='Ext-EventObject-property-G'> /** Key constant @type Number */
130 <span id='Ext-EventObject-property-H'> /** Key constant @type Number */
132 <span id='Ext-EventObject-property-I'> /** Key constant @type Number */
134 <span id='Ext-EventObject-property-J'> /** Key constant @type Number */
136 <span id='Ext-EventObject-property-K'> /** Key constant @type Number */
138 <span id='Ext-EventObject-property-L'> /** Key constant @type Number */
140 <span id='Ext-EventObject-property-M'> /** Key constant @type Number */
142 <span id='Ext-EventObject-property-N'> /** Key constant @type Number */
144 <span id='Ext-EventObject-property-O'> /** Key constant @type Number */
146 <span id='Ext-EventObject-property-P'> /** Key constant @type Number */
148 <span id='Ext-EventObject-property-Q'> /** Key constant @type Number */
150 <span id='Ext-EventObject-property-R'> /** Key constant @type Number */
152 <span id='Ext-EventObject-property-S'> /** Key constant @type Number */
154 <span id='Ext-EventObject-property-T'> /** Key constant @type Number */
156 <span id='Ext-EventObject-property-U'> /** Key constant @type Number */
158 <span id='Ext-EventObject-property-V'> /** Key constant @type Number */
160 <span id='Ext-EventObject-property-W'> /** Key constant @type Number */
162 <span id='Ext-EventObject-property-X'> /** Key constant @type Number */
164 <span id='Ext-EventObject-property-Y'> /** Key constant @type Number */
166 <span id='Ext-EventObject-property-Z'> /** Key constant @type Number */
168 <span id='Ext-EventObject-property-CONTEXT_MENU'> /** Key constant @type Number */
169 </span> CONTEXT_MENU: 93,
170 <span id='Ext-EventObject-property-NUM_ZERO'> /** Key constant @type Number */
171 </span> NUM_ZERO: 96,
172 <span id='Ext-EventObject-property-NUM_ONE'> /** Key constant @type Number */
174 <span id='Ext-EventObject-property-NUM_TWO'> /** Key constant @type Number */
176 <span id='Ext-EventObject-property-NUM_THREE'> /** Key constant @type Number */
177 </span> NUM_THREE: 99,
178 <span id='Ext-EventObject-property-NUM_FOUR'> /** Key constant @type Number */
179 </span> NUM_FOUR: 100,
180 <span id='Ext-EventObject-property-NUM_FIVE'> /** Key constant @type Number */
181 </span> NUM_FIVE: 101,
182 <span id='Ext-EventObject-property-NUM_SIX'> /** Key constant @type Number */
183 </span> NUM_SIX: 102,
184 <span id='Ext-EventObject-property-NUM_SEVEN'> /** Key constant @type Number */
185 </span> NUM_SEVEN: 103,
186 <span id='Ext-EventObject-property-NUM_EIGHT'> /** Key constant @type Number */
187 </span> NUM_EIGHT: 104,
188 <span id='Ext-EventObject-property-NUM_NINE'> /** Key constant @type Number */
189 </span> NUM_NINE: 105,
190 <span id='Ext-EventObject-property-NUM_MULTIPLY'> /** Key constant @type Number */
191 </span> NUM_MULTIPLY: 106,
192 <span id='Ext-EventObject-property-NUM_PLUS'> /** Key constant @type Number */
193 </span> NUM_PLUS: 107,
194 <span id='Ext-EventObject-property-NUM_MINUS'> /** Key constant @type Number */
195 </span> NUM_MINUS: 109,
196 <span id='Ext-EventObject-property-NUM_PERIOD'> /** Key constant @type Number */
197 </span> NUM_PERIOD: 110,
198 <span id='Ext-EventObject-property-NUM_DIVISION'> /** Key constant @type Number */
199 </span> NUM_DIVISION: 111,
200 <span id='Ext-EventObject-property-F1'> /** Key constant @type Number */
202 <span id='Ext-EventObject-property-F2'> /** Key constant @type Number */
204 <span id='Ext-EventObject-property-F3'> /** Key constant @type Number */
206 <span id='Ext-EventObject-property-F4'> /** Key constant @type Number */
208 <span id='Ext-EventObject-property-F5'> /** Key constant @type Number */
210 <span id='Ext-EventObject-property-F6'> /** Key constant @type Number */
212 <span id='Ext-EventObject-property-F7'> /** Key constant @type Number */
214 <span id='Ext-EventObject-property-F8'> /** Key constant @type Number */
216 <span id='Ext-EventObject-property-F9'> /** Key constant @type Number */
218 <span id='Ext-EventObject-property-F10'> /** Key constant @type Number */
220 <span id='Ext-EventObject-property-F11'> /** Key constant @type Number */
222 <span id='Ext-EventObject-property-F12'> /** Key constant @type Number */
224 <span id='Ext-EventObject-property-WHEEL_SCALE'> /**
225 </span> * The mouse wheel delta scaling factor. This value depends on browser version and OS and
226 * attempts to produce a similar scrolling experience across all platforms and browsers.
228 * To change this value:
230 * Ext.EventObjectImpl.prototype.WHEEL_SCALE = 72;
235 WHEEL_SCALE: (function () {
239 // Firefox uses 3 on all platforms
241 } else if (Ext.isMac) {
242 // Continuous scrolling devices have momentum and produce much more scroll than
243 // discrete devices on the same OS and browser. To make things exciting, Safari
244 // (and not Chrome) changed from small values to 120 (like IE).
246 if (Ext.isSafari && Ext.webKitVersion >= 532.0) {
247 // Safari changed the scrolling factor to match IE (for details see
248 // https://bugs.webkit.org/show_bug.cgi?id=24368). The WebKit version where this
249 // change was introduced was 532.0
250 // Detailed discussion:
251 // https://bugs.webkit.org/show_bug.cgi?id=29601
252 // http://trac.webkit.org/browser/trunk/WebKit/chromium/src/mac/WebInputEventFactory.mm#L1063
255 // MS optical wheel mouse produces multiples of 12 which is close enough
256 // to help tame the speed of the continuous mice...
260 // Momentum scrolling produces very fast scrolling, so increase the scale factor
261 // to help produce similar results cross platform. This could be even larger and
262 // it would help those mice, but other mice would become almost unusable as a
263 // result (since we cannot tell which device type is in use).
266 // IE, Opera and other Windows browsers use 120.
273 <span id='Ext-EventObject-property-clickRe'> /**
274 </span> * Simple click regex
277 clickRe: /(dbl)?click/,
278 // safari keypress events for special keys return bad keycodes
285 63276: 33, // page up
286 63277: 34, // page down
291 // normalize button clicks, don't see any way to feature detect this.
302 constructor: function(event, freezeEvent){
304 this.setEvent(event.browserEvent || event, freezeEvent);
308 setEvent: function(event, freezeEvent){
309 var me = this, button, options;
311 if (event == me || (event && event.browserEvent)) { // already wrapped
314 me.browserEvent = event;
317 button = event.button ? me.btnMap[event.button] : (event.which ? event.which - 1 : -1);
318 if (me.clickRe.test(event.type) && button == -1) {
324 shiftKey: event.shiftKey,
325 // mac metaKey behaves like ctrlKey
326 ctrlKey: event.ctrlKey || event.metaKey || false,
327 altKey: event.altKey,
328 // in getKey these will be normalized for the mac
329 keyCode: event.keyCode,
330 charCode: event.charCode,
331 // cache the targets for the delayed and or buffered events
332 target: Ext.EventManager.getTarget(event),
333 relatedTarget: Ext.EventManager.getRelatedTarget(event),
334 currentTarget: event.currentTarget,
335 xy: (freezeEvent ? me.getXY() : null)
349 Ext.apply(me, options);
353 <span id='Ext-EventObject-method-stopEvent'> /**
354 </span> * Stop the event (preventDefault and stopPropagation)
356 stopEvent: function(){
357 this.stopPropagation();
358 this.preventDefault();
361 <span id='Ext-EventObject-method-preventDefault'> /**
362 </span> * Prevents the browsers default handling of the event.
364 preventDefault: function(){
365 if (this.browserEvent) {
366 Ext.EventManager.preventDefault(this.browserEvent);
370 <span id='Ext-EventObject-method-stopPropagation'> /**
371 </span> * Cancels bubbling of the event.
373 stopPropagation: function(){
374 var browserEvent = this.browserEvent;
377 if (browserEvent.type == 'mousedown') {
378 Ext.EventManager.stoppedMouseDownEvent.fire(this);
380 Ext.EventManager.stopPropagation(browserEvent);
384 <span id='Ext-EventObject-method-getCharCode'> /**
385 </span> * Gets the character code for the event.
388 getCharCode: function(){
389 return this.charCode || this.keyCode;
392 <span id='Ext-EventObject-method-getKey'> /**
393 </span> * Returns a normalized keyCode for the event.
394 * @return {Number} The key code
397 return this.normalizeKey(this.keyCode || this.charCode);
400 <span id='Ext-EventObject-method-normalizeKey'> /**
401 </span> * Normalize key codes across browsers
403 * @param {Number} key The key code
404 * @return {Number} The normalized code
406 normalizeKey: function(key){
407 // can't feature detect this
408 return Ext.isWebKit ? (this.safariKeys[key] || key) : key;
411 <span id='Ext-EventObject-method-getPageX'> /**
412 </span> * Gets the x coordinate of the event.
414 * @deprecated 4.0 Replaced by {@link #getX}
416 getPageX: function(){
420 <span id='Ext-EventObject-method-getPageY'> /**
421 </span> * Gets the y coordinate of the event.
423 * @deprecated 4.0 Replaced by {@link #getY}
425 getPageY: function(){
429 <span id='Ext-EventObject-method-getX'> /**
430 </span> * Gets the x coordinate of the event.
434 return this.getXY()[0];
437 <span id='Ext-EventObject-method-getY'> /**
438 </span> * Gets the y coordinate of the event.
442 return this.getXY()[1];
445 <span id='Ext-EventObject-method-getXY'> /**
446 </span> * Gets the page coordinates of the event.
447 * @return {Array} The xy values like [x, y]
452 this.xy = Ext.EventManager.getPageXY(this.browserEvent);
457 <span id='Ext-EventObject-method-getTarget'> /**
458 </span> * Gets the target for the event.
459 * @param {String} selector (optional) A simple selector to filter the target or look for an ancestor of the target
460 * @param {Number/Mixed} maxDepth (optional) The max depth to search as a number or element (defaults to 10 || document.body)
461 * @param {Boolean} returnEl (optional) True to return a Ext.core.Element object instead of DOM node
462 * @return {HTMLelement}
464 getTarget : function(selector, maxDepth, returnEl){
466 return Ext.fly(this.target).findParent(selector, maxDepth, returnEl);
468 return returnEl ? Ext.get(this.target) : this.target;
471 <span id='Ext-EventObject-method-getRelatedTarget'> /**
472 </span> * Gets the related target.
473 * @param {String} selector (optional) A simple selector to filter the target or look for an ancestor of the target
474 * @param {Number/Mixed} maxDepth (optional) The max depth to search as a number or element (defaults to 10 || document.body)
475 * @param {Boolean} returnEl (optional) True to return a Ext.core.Element object instead of DOM node
476 * @return {HTMLElement}
478 getRelatedTarget : function(selector, maxDepth, returnEl){
480 return Ext.fly(this.relatedTarget).findParent(selector, maxDepth, returnEl);
482 return returnEl ? Ext.get(this.relatedTarget) : this.relatedTarget;
485 <span id='Ext-EventObject-method-correctWheelDelta'> /**
486 </span> * Correctly scales a given wheel delta.
487 * @param {Number} delta The delta value.
489 correctWheelDelta : function (delta) {
490 var scale = this.WHEEL_SCALE,
491 ret = Math.round(delta / scale + 0.5);
493 if (!ret && delta) {
494 ret = (delta < 0) ? -1 : 1; // don't allow non-zero deltas to go to zero!
500 <span id='Ext-EventObject-method-getWheelDeltas'> /**
501 </span> * Returns the mouse wheel deltas for this event.
502 * @return {Object} An object with "x" and "y" properties holding the mouse wheel deltas.
504 getWheelDeltas : function () {
506 event = me.browserEvent,
507 dx = 0, dy = 0; // the deltas
509 if (Ext.isDefined(event.wheelDeltaX)) { // WebKit has both dimensions
510 dx = event.wheelDeltaX;
511 dy = event.wheelDeltaY;
512 } else if (event.wheelDelta) { // old WebKit and IE
513 dy = event.wheelDelta;
514 } else if (event.detail) { // Gecko
515 dy = -event.detail; // gecko is backwards
517 // Gecko sometimes returns really big values if the user changes settings to
518 // scroll a whole page per scroll
521 } else if (dy < -100) {
525 // Firefox 3.1 adds an axis field to the event to indicate direction of
526 // scroll. See https://developer.mozilla.org/en/Gecko-Specific_DOM_Events
527 if (Ext.isDefined(event.axis) && event.axis === event.HORIZONTAL_AXIS) {
534 x: me.correctWheelDelta(dx),
535 y: me.correctWheelDelta(dy)
539 <span id='Ext-EventObject-method-getWheelDelta'> /**
540 </span> * Normalizes mouse wheel y-delta across browsers. To get x-delta information, use
541 * {@link #getWheelDeltas} instead.
542 * @return {Number} The mouse wheel y-delta
544 getWheelDelta : function(){
545 var deltas = this.getWheelDeltas();
550 <span id='Ext-EventObject-method-within'> /**
551 </span> * 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.
552 * Example usage:<pre><code>
553 // Handle click on any child of an element
554 Ext.getBody().on('click', function(e){
555 if(e.within('some-el')){
556 alert('Clicked on a child of some-el!');
560 // Handle click directly on an element, ignoring clicks on child nodes
561 Ext.getBody().on('click', function(e,t){
562 if((t.id == 'some-el') && !e.within(t, true)){
563 alert('Clicked directly on some-el!');
566 </code></pre>
567 * @param {Mixed} el The id, DOM element or Ext.core.Element to check
568 * @param {Boolean} related (optional) true to test if the related target is within el instead of the target
569 * @param {Boolean} allowEl {optional} true to also check if the passed element is the target or related target
572 within : function(el, related, allowEl){
574 var t = related ? this.getRelatedTarget() : this.getTarget(),
578 result = Ext.fly(el).contains(t);
579 if (!result && allowEl) {
580 result = t == Ext.getDom(el);
588 <span id='Ext-EventObject-method-isNavKeyPress'> /**
589 </span> * Checks if the key pressed was a "navigation" key
590 * @return {Boolean} True if the press is a navigation keypress
592 isNavKeyPress : function(){
594 k = this.normalizeKey(me.keyCode);
596 return (k >= 33 && k <= 40) || // Page Up/Down, End, Home, Left, Up, Right, Down
602 <span id='Ext-EventObject-method-isSpecialKey'> /**
603 </span> * Checks if the key pressed was a "special" key
604 * @return {Boolean} True if the press is a special keypress
606 isSpecialKey : function(){
607 var k = this.normalizeKey(this.keyCode);
608 return (this.type == 'keypress' && this.ctrlKey) ||
609 this.isNavKeyPress() ||
610 (k == this.BACKSPACE) || // Backspace
611 (k >= 16 && k <= 20) || // Shift, Ctrl, Alt, Pause, Caps Lock
612 (k >= 44 && k <= 46); // Print Screen, Insert, Delete
615 <span id='Ext-EventObject-method-getPoint'> /**
616 </span> * Returns a point object that consists of the object coordinates.
617 * @return {Ext.util.Point} point
619 getPoint : function(){
620 var xy = this.getXY();
621 return Ext.create('Ext.util.Point', xy[0], xy[1]);
624 <span id='Ext-EventObject-method-hasModifier'> /**
625 </span> * Returns true if the control, meta, shift or alt key was pressed during this event.
628 hasModifier : function(){
629 return this.ctrlKey || this.altKey || this.shiftKey || this.metaKey;
632 <span id='Ext-EventObject-method-injectEvent'> /**
633 </span> * Injects a DOM event using the data in this object and (optionally) a new target.
634 * This is a low-level technique and not likely to be used by application code. The
635 * currently supported event types are:
636 * <p><b>HTMLEvents</b></p>
638 * <li>load</li>
639 * <li>unload</li>
640 * <li>select</li>
641 * <li>change</li>
642 * <li>submit</li>
643 * <li>reset</li>
644 * <li>resize</li>
645 * <li>scroll</li>
647 * <p><b>MouseEvents</b></p>
649 * <li>click</li>
650 * <li>dblclick</li>
651 * <li>mousedown</li>
652 * <li>mouseup</li>
653 * <li>mouseover</li>
654 * <li>mousemove</li>
655 * <li>mouseout</li>
657 * <p><b>UIEvents</b></p>
659 * <li>focusin</li>
660 * <li>focusout</li>
661 * <li>activate</li>
662 * <li>focus</li>
663 * <li>blur</li>
665 * @param {Element/HTMLElement} target If specified, the target for the event. This
666 * is likely to be used when relaying a DOM event. If not specified, {@link #getTarget}
667 * is used to determine the target.
669 injectEvent: function () {
671 dispatchers = {}; // keyed by event type (e.g., 'mousedown')
673 // Good reference: http://developer.yahoo.com/yui/docs/UserAction.js.html
675 // IE9 has createEvent, but this code causes major problems with htmleditor (it
676 // blocks all mouse events and maybe more). TODO
678 if (!Ext.isIE && document.createEvent) { // if (DOM compliant)
680 createHtmlEvent: function (doc, type, bubbles, cancelable) {
681 var event = doc.createEvent('HTMLEvents');
683 event.initEvent(type, bubbles, cancelable);
687 createMouseEvent: function (doc, type, bubbles, cancelable, detail,
688 clientX, clientY, ctrlKey, altKey, shiftKey, metaKey,
689 button, relatedTarget) {
690 var event = doc.createEvent('MouseEvents'),
691 view = doc.defaultView || window;
693 if (event.initMouseEvent) {
694 event.initMouseEvent(type, bubbles, cancelable, view, detail,
695 clientX, clientY, clientX, clientY, ctrlKey, altKey,
696 shiftKey, metaKey, button, relatedTarget);
697 } else { // old Safari
698 event = doc.createEvent('UIEvents');
699 event.initEvent(type, bubbles, cancelable);
701 event.detail = detail;
702 event.screenX = clientX;
703 event.screenY = clientY;
704 event.clientX = clientX;
705 event.clientY = clientY;
706 event.ctrlKey = ctrlKey;
707 event.altKey = altKey;
708 event.metaKey = metaKey;
709 event.shiftKey = shiftKey;
710 event.button = button;
711 event.relatedTarget = relatedTarget;
717 createUIEvent: function (doc, type, bubbles, cancelable, detail) {
718 var event = doc.createEvent('UIEvents'),
719 view = doc.defaultView || window;
721 event.initUIEvent(type, bubbles, cancelable, view, detail);
725 fireEvent: function (target, type, event) {
726 target.dispatchEvent(event);
729 fixTarget: function (target) {
730 // Safari3 doesn't have window.dispatchEvent()
731 if (target == window && !target.dispatchEvent) {
738 } else if (document.createEventObject) { // else if (IE)
739 var crazyIEButtons = { 0: 1, 1: 4, 2: 2 };
742 createHtmlEvent: function (doc, type, bubbles, cancelable) {
743 var event = doc.createEventObject();
744 event.bubbles = bubbles;
745 event.cancelable = cancelable;
749 createMouseEvent: function (doc, type, bubbles, cancelable, detail,
750 clientX, clientY, ctrlKey, altKey, shiftKey, metaKey,
751 button, relatedTarget) {
752 var event = doc.createEventObject();
753 event.bubbles = bubbles;
754 event.cancelable = cancelable;
755 event.detail = detail;
756 event.screenX = clientX;
757 event.screenY = clientY;
758 event.clientX = clientX;
759 event.clientY = clientY;
760 event.ctrlKey = ctrlKey;
761 event.altKey = altKey;
762 event.shiftKey = shiftKey;
763 event.metaKey = metaKey;
764 event.button = crazyIEButtons[button] || button;
765 event.relatedTarget = relatedTarget; // cannot assign to/fromElement
769 createUIEvent: function (doc, type, bubbles, cancelable, detail) {
770 var event = doc.createEventObject();
771 event.bubbles = bubbles;
772 event.cancelable = cancelable;
776 fireEvent: function (target, type, event) {
777 target.fireEvent('on' + type, event);
780 fixTarget: function (target) {
781 if (target == document) {
782 // IE6,IE7 thinks window==document and doesn't have window.fireEvent()
783 // IE6,IE7 cannot properly call document.fireEvent()
784 return document.documentElement;
796 load: [false, false],
797 unload: [false, false],
798 select: [true, false],
799 change: [true, false],
800 submit: [true, true],
801 reset: [true, false],
802 resize: [true, false],
803 scroll: [true, false]
805 function (name, value) {
806 var bubbles = value[0], cancelable = value[1];
807 dispatchers[name] = function (targetEl, srcEvent) {
808 var e = API.createHtmlEvent(name, bubbles, cancelable);
809 API.fireEvent(targetEl, name, e);
816 function createMouseEventDispatcher (type, detail) {
817 var cancelable = (type != 'mousemove');
818 return function (targetEl, srcEvent) {
819 var xy = srcEvent.getXY(),
820 e = API.createMouseEvent(targetEl.ownerDocument, type, true, cancelable,
821 detail, xy[0], xy[1], srcEvent.ctrlKey, srcEvent.altKey,
822 srcEvent.shiftKey, srcEvent.metaKey, srcEvent.button,
823 srcEvent.relatedTarget);
824 API.fireEvent(targetEl, type, e);
828 Ext.each(['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mousemove', 'mouseout'],
829 function (eventName) {
830 dispatchers[eventName] = createMouseEventDispatcher(eventName, 1);
837 focusin: [true, false],
838 focusout: [true, false],
839 activate: [true, true],
840 focus: [false, false],
843 function (name, value) {
844 var bubbles = value[0], cancelable = value[1];
845 dispatchers[name] = function (targetEl, srcEvent) {
846 var e = API.createUIEvent(targetEl.ownerDocument, name, bubbles, cancelable, 1);
847 API.fireEvent(targetEl, name, e);
853 // not even sure what ancient browsers fall into this category...
855 dispatchers = {}; // never mind all those we just built :P
858 fixTarget: function (t) {
864 function cannotInject (target, srcEvent) {
866 // TODO log something
870 return function (target) {
872 dispatcher = dispatchers[me.type] || cannotInject,
873 t = target ? (target.dom || target) : me.getTarget();
875 t = API.fixTarget(t);
878 }() // call to produce method
882 Ext.EventObject = new Ext.EventObjectImpl();