Please note that addEventHandler and removeEventHandler are static methods and so don't require construction first.
Typical usage of the instance passes an event object as a parameter:
this.mouseDown = function(event) { var evt = new wwEvent(event); if (evt.source != Instance.dragHandle) return; Instance.windowObj.control.style.position = "absolute"; Instance.deltaX = evt.offsetX; // get container relative offset Instance.deltaY = evt.offsetY; Instance.dragActivate(event); evt.consume(); // stop bubbling the event }
Static usage of the wwEvent class:
this.dragActivate = function(event) { Instance.windowObj.setOpacity(Instance.dragOpacity); wwEvent.addEventListener(document,"mousemove",Instance.mouseMove,false); wwEvent.addEventListener(document,"mouseup",Instance.mouseUp,false); } this.dragDeActivate = function(event) { wwEvent.removeEventListener( document,"mousemove",Instance.mouseMove,false); wwEvent.removeEventListener( document,"mouseup",Instance.mouseUp,false); Instance.windowObj.setOpacity(1); }
Member | Description | |
---|---|---|
Constructor | Initializes this instance with a DOM Event object. | |
addEventListener | Hooks up an event handler to a DOM event. This mechanism is additive so multiple handlers can be attached to the same event. o.wwEvent.addEventListener(target,eventname,handler,bubbles) | |
consume | Stops event propagation if possible by keeping the event from bubbling up the DOM hierarchy. This should be used whenever handling an event and assuming that there won't be any further events fired up the chain. o.wwEvent.consume() | |
removeEventListener | Removes an event handler from a DOM event. This function is the reverse of addEventListener and takes the exact same parameter signature. o.removeEventListener(target,eventname,handler,bubbles) | |
clientX | Client relevant position of the X (left) coordinate that is adjusted for scroll position. | |
clientY | Client relevant position of the Y (top) coordinate that is adjusted for scroll position. | |
offsetX | The x position of the mouse cursor in parent container relative format. | |
offsetY | The y position of the mouse cursor in parent container relative format. | |
source | The source control that initiated the current event. | |
x | The x position of the mouse cursor in document (Page) relative format. | |
y | The y position of the mouse cursor in document (Page) relative format. |