1 jls.loader.provide('jls.gui.Event'); 2 3 jls.gui.Event = jls.lang.Class.create( /** @lends jls.gui.Event.prototype */ 4 { 5 //bubbles: Returns a Boolean value that indicates whether or not an event is a bubbling event 6 //cancelable: Returns a Boolean value that indicates whether or not an event can have its default action prevented 7 //currentTarget: Returns the element whose event listeners triggered the event 8 //eventPhase: Returns which phase of the event flow is currently being evaluated 9 /** 10 * Creates an event. 11 * 12 * @param {String} type The event type. 13 * @constructs 14 * @class This class represents a graphical event. 15 */ 16 initialize : function(type, target) { 17 this.type = type; 18 this.target = target; 19 this.timeStamp = 0; 20 }, 21 //relatedTarget: Returns the element related to the element that triggered the event 22 setMouse : function(button, clientX, clientY, screenX, screenY) { 23 this.button = button; 24 this.clientX = clientX; 25 this.clientY = clientY; 26 this.screenX = screenX; 27 this.screenY = screenY; 28 return this; 29 }, 30 setKeyModifiers : function(altKey, ctrlKey, metaKey, shiftKey) { 31 this.altKey = altKey; 32 this.ctrlKey = ctrlKey; 33 this.metaKey = metaKey; 34 this.shiftKey = shiftKey; 35 return this; 36 }, 37 // Internet Explorer uses event.keyCode to retrieve the character that was pressed and Netscape/Firefox/Opera uses event.which 38 setKey : function(which) { 39 this.which = which; 40 return this; 41 }, 42 stopPropagation : function() { 43 return this; 44 }, 45 preventDefault : function() { 46 return this; 47 } 48 }); 49 50 Object.extend(jls.gui.Event, /** @lends jls.gui.Event */ 51 { 52 MOUSE_BUTTON_LEFT : 0, 53 MOUSE_BUTTON_MIDDLE : 1, 54 MOUSE_BUTTON_RIGHT : 2, 55 createMouseEvent : function(type, target, button, clientX, clientY, screenX, screenY) { 56 var event = new jls.gui.Event(type, target); 57 event.setMouse(button, clientX, clientY, screenX, screenY); 58 return event; 59 }, 60 createKeyEvent : function(type, target, which) { 61 var event = new jls.gui.Event(type, target); 62 event.setKey(which); 63 return event; 64 } 65 }); 66 67