The Event class provides utilities for working with the browser event object, listening to and capturing events, and decorating Framework Objects with an API for scoping handlers back to the object.
Utilities for DOM Events.
See Using event utilities for an example of implementating the script on a page.
This example shows how to use the event buffer and scopeHandler mechanisms to preserve the event handler context to a specific object instance.
<p id = "oPara">Test paragraph</p>
<script type = "text/javascript">
var oObject = Hemi.newObject("DemoType","1.0",true);
// Add the scopeHandler method for this object with addScopeBuffer
Hemi.event.addScopeBuffer(oObject);
// Create an event handler wrapper with scopeHandler 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.scopeHandler("click",0,0,1);
oObject._handle_click = function(e){
var oEvent = Hemi.event.getEvent(e);
var oSource = Hemi.event.getEventSource(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 scopeHandler method.
Hemi.event.addEventListener(oPara, "click", oObject._prehandle_click);
</script>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 scopeHandler method. Method is virtual and can be overridden.
v = _handle_event( )
v as variant: Returns developer specified value.
Internal event handler used to establish context and to invoke the custom handler.
v = _prehandle_event( )
v as variant: Returns value from
Creates the scopeHandler method on the specified object.
void addScopeBuffer( e )
Cancels the event.
void cancelEvent( o )
Returns the event object, where the specified parameter may or may not be the event object depending on the browser.
e = getEvent( o )
e as object: The event object.
Returns the event destination or target object.
e = getEventDestination( o )
e as object: The event destination object.
Returns the event origination object.
e = getEventOrigination( o )
e as object: The event origination or source object.
Returns the event source object.
e = getEventSource( o )
e as object: The event source object.
Creates a custom event handler, _prehandle_event, which invokes _handle_event for the specified object, using the specified context. This method is created by addScopeBuffer. Method is virtual and can be overridden.
f = scopeHandler( s, r, x, l )
f as function: Custom event handler function.
[ Hemi JavaScript Framework - Stephen W. Cote, 2002 - 2009. ]