static org.cote.js.dom.event
version 1.9.18
Utilities for DOM Events.
See Using event utilities for an example of implementating the script on a page. This class participates in the engine library.
Index
Example Index
- Using event utilities: This example shows how to use the event buffer and createHandler mechanisms to preserve the event handler context to a specific object instance.
Property Index
Method Index
- private _gevt: Returns the event object, where the specified parameter may or may not be the event object depending on the browser.
- private _gevt: Returns the event destination or target object.
- private _gevt_cancel: Cancels the event.
- private _gevt_org: Returns the event origination object.
- private _gevt_src: Returns the event source object.
- private _handle_event (internal): A developer specified event handler that is invoked after binding an event to the _prehandle_event handler, and which has the context specified by the createHandler method.
- private _prehandle_event (internal): Internal event handler used to establish context and to invoke the custom handler.
- private addEventBuffer: Creates the createHandler method on the specified object.
- public addEventListener: Adds an event listener to the specified object
- private createHandler (internal): Creates a custom event handler, _prehandle_event, which invokes _handle_event for the specified object, using the specified context. This method must be created with addEventBuffer.
- public disableMotionCapture: Removes motion capture (mousemove and mouseup) from the specified object.
- public enableMotionCapture: Enables motion capture (mousemove and mouseup) for the specified object.
- public getAbsoluteLeft: Returns the absolute left position of the specified node.
- public getAbsolutePosition (internal): Returns the absolute position of the specified node.
- public getAbsoluteTop: Returns the absolute top position of the specified node.
- public removeEventListener: Removes an event listener from the specified object
Examples
Using event utilities
This example shows how to use the event buffer and createHandler mechanisms to preserve the event handler context to a specific object instance.
Example Code
<p id = "oPara">Test paragraph</p>
<script type = "text/javascript">
var oObject = org.cote.js.newObject("DemoType","1.0",true);
// Add the createHandler method for this object with addEventBuffer
org.cote.js.dom.event.addEventBuffer(oObject);
// Create an event handler wrapper with createHandler for an onclick event.
// Specify the event name and the bit to use the ObjectRegistry.
// This creates oObject._prehandle_click which will invoke oObject._handle_click.
oObject.createHandler("click",0,0,1);
oObject._handle_click = function(e){
var oEvent = org.cote.js.dom.event._gevt(e);
var oSource = org.cote.js.dom.event._gevt_src(e);
// The 'this' object refers to the instance of oObject
};
// Add the onclick event to the paragraph element, oPara
var oPara = document.getElementById("oPara");
// Use the _prehandle_click created by the createHandler method.
org.cote.js.dom.event.addEventListener(oPara, "click", oObject._prehandle_click);
</script>Properties
object_version
The version of the object
Syntax
String = org.cote.js.dom.event.object_version
Methods
_gevt
Returns the event object, where the specified parameter may or may not be the event object depending on the browser. Method is private and should not be directly referenced.
Syntax
e = _gevt(
o
)
Parameters
- o as object : Possible event object
Returns
e as object: The event object.
_gevt
Returns the event destination or target object. Method is private and should not be directly referenced.
Syntax
e = _gevt(
o
)
Parameters
- o as object : Possible event object
Returns
e as object: The event destination object.
_gevt_cancel
Cancels the event. Method is private and should not be directly referenced.
Syntax
void _gevt_cancel(
o
)
Parameters
- o as object : Possible event object
_gevt_org
Returns the event origination object. Method is private and should not be directly referenced.
Syntax
e = _gevt_org(
o
)
Parameters
- o as object : Possible event object
Returns
e as object: The event origination or source object.
_gevt_src
Returns the event source object. Method is private and should not be directly referenced.
Syntax
e = _gevt_src(
o
)
Parameters
- o as object : Possible event object
Returns
e as object: The event source object.
_handle_event
A developer specified event handler that is invoked after binding an event to the _prehandle_event handler, and which has the context specified by the createHandler method. Method is private and should not be directly referenced.
Syntax
v = _handle_event(
)
Returns
v as variant: Returns developer specified value.
_prehandle_event
Internal event handler used to establish context and to invoke the custom handler. Method is private and should not be directly referenced.
Syntax
v = _prehandle_event(
)
Returns
v as variant: Returns value from
addEventBuffer
Creates the createHandler method on the specified object. Method is private and should not be directly referenced.
Syntax
void addEventBuffer(
e
)
Parameters
- e as object : A possible event object. Use
addEventListener
Adds an event listener to the specified object
Syntax
void addEventListener(
o, e, f, b
)
Parameters
- o as object : DOM Node for which the event listener will be added.
- e as String : Name of the event.
- f as function : Delegate to be invoked when the specified event fires for the object.
- b as boolean (optional): Bit indicating whether the event should be trapped on this object.
createHandler
Creates a custom event handler, _prehandle_event, which invokes _handle_event for the specified object, using the specified context. This method must be created with addEventBuffer. Method is private and should not be directly referenced.
Syntax
f = createHandler(
s, r, x, l
)
Parameters
- s as String : Event name, such as
- r as object (optional): Reference object for which the event handler should have context. Object must be registered with ObjectRegistry.
- x as boolean (optional): Bit indicating whether or not the custom handler should be set on the specified object.
- l as boolean (optional): Bit indicating whether the context should be referenced using the ObjectRegistry if true, or the this reference if false.
Returns
f as function: Custom event handler function.
disableMotionCapture
Removes motion capture (mousemove and mouseup) from the specified object.
Syntax
void disableMotionCapture(
o
)
Parameters
- o as object : DOM Node for which motion capture was enabled. Object must directly implement mousemove and mouseup event handlers.
enableMotionCapture
Enables motion capture (mousemove and mouseup) for the specified object.
Syntax
void enableMotionCapture(
o
)
Parameters
- o as object : DOM Node for which motion capture will be enabled. Object must directly implement mousemove and mouseup event handlers.
getAbsoluteLeft
Returns the absolute left position of the specified node.
Syntax
i = getAbsoluteLeft(
o, r
)
Parameters
- o as object : Source DOM Node.
- r as object (optional): Reference DOM Node.
Returns
i as int: The absolute left of the specified object from the parent window.
getAbsolutePosition
Returns the absolute position of the specified node.
Syntax
i = getAbsolutePosition(
o, r, b
)
Parameters
- o as object : Source DOM Node.
- r as object (optional): Reference DOM Node.
- b as boolean : Bit indicating the position type
Returns
i as int: The absolute position of the specified object from the parent window.
getAbsoluteTop
Returns the absolute top position of the specified node.
Syntax
i = getAbsoluteTop(
o, r
)
Parameters
- o as object : Source DOM Node.
- r as object (optional): Reference DOM Node.
Returns
i as int: The absolute top of the specified object from the parent window.
removeEventListener
Removes an event listener from the specified object
Syntax
void removeEventListener(
o, e, f, b
)
Parameters
- o as object : DOM Node for which the event listener will be added.
- e as String : Name of the event.
- f as function : Delegate to be invoked when the specified event fires for the object.
- b as boolean (optional): Bit indicating whether the event should be trapped on this object.