ui/ EventManager.js

This library attempts to abstract events so that many controls can use, say, mouse down for example, instead of taking total control of the event The main point of this library is to delegate events to controls that care.  Often times, DHTML contorls (tree controls for instance) will take hold of the document on click event, and then no other contorl or process can get that event.  This library takes control of the events then allows you to register with it so that everyone can get notified in turn.  To register, make a function that takes one parameter.  The parameter will be the event object, and will get passed in by the manager to your function when the event gets fired.  So for example the following code creates an alert box when anything on the page is clicked:

click_happened = function(event){ alert(event.target) };
neuro_addClickListener(click_happened);

The event object has a few tweaks to make it act the same on all browsers, but the most common part of the event is the target property which points to the item that fired the event.

Copyright

2004 Rob Rohan (robr.nosp@m.ohan@gmai.nosp@m.l.com) All rights reserved

Related

util/BrowserSniffer.js util/Log.js

Summary
This library attempts to abstract events so that many controls can use, say, mouse down for example, instead of taking total control of the event The main point of this library is to delegate events to controls that care.
register an onload listner
register a mouse down listener
register a mouse up listener
register a click listener
register a move listener
add a keyDownListener
add a keyUpListener
add a key press Listener
Gets the key code from an event i.e.
Gets the key from an event i.e.

Variables

EVENTMANAGER_VERSION - the library version

SysDocument - a handle to (or wrapper for) the document

neuro_onloadListeners all the load listeners

neuro_clickListeners array of click listeners

neuro_mdownListeners all the mouse down listeners

neuro_mupListeners mouse up listeners

neuro_moveListeners array of mouse move listeners

neuro_keyDownListeners key down listeners

neuro_keyUpListeners key up listeners

neuro_keyPressListeners key press listeners

Functions

neuro_addLoadListener

function neuro_addLoadListener(func)

register an onload listner

Parameters

functhe call back function to run when this event occurs

neuro_addMouseDownListener

function neuro_addMouseDownListener(func)

register a mouse down listener

Parameters

functhe call back function to run when this event occurs

neuro_addMouseUpListener

function neuro_addMouseUpListener(func)

register a mouse up listener

Parameters

functhe call back function to run when this event occurs

neuro_addClickListener

function neuro_addClickListener(func)

register a click listener

Parameters

functhe call back function to run when this event occurs

neuro_addMoveListener

function neuro_addMoveListener(func)

register a move listener

Parameters

functhe call back function to run when this event occurs

neuro_addKeyDownListener

function neuro_addKeyDownListener(func)

add a keyDownListener

Parameters

functhe call back function to run when this event occurs

neuro_addKeyUpListener

function neuro_addKeyUpListener(func)

add a keyUpListener

Parameters

functhe call back function to run when this event occurs

neuro_addKeyPressListener

function neuro_addKeyPressListener(func)

add a key press Listener

Parameters

functhe call back function to run when this event occurs

__normalizeEvent

function __normalizeEvent(evt)
helper function to handle IE bug for even handlingmostly makes just makes sure an event is an event.  Not really an API function but it might be useful out side this library.

Parameters

evtan event (could be IE could be Mozilla)

Returns

a uniform event object

neuro_getKeyCodeFromEvent

function neuro_getKeyCodeFromEvent(evt)

Gets the key code from an event i.e.  65

Parameter

evtthe event to get the key code from

Returns

the ascii key code

neuro_getKeyFromEvent

function neuro_getKeyFromEvent(evt)

Gets the key from an event i.e.  “A”

Parameters

evtthe event in which to look

Returns

char from a key event

function neuro_addLoadListener(func)
register an onload listner
function neuro_addMouseDownListener(func)
register a mouse down listener
function neuro_addMouseUpListener(func)
register a mouse up listener
function neuro_addClickListener(func)
register a click listener
function neuro_addMoveListener(func)
register a move listener
function neuro_addKeyDownListener(func)
add a keyDownListener
function neuro_addKeyUpListener(func)
add a keyUpListener
function neuro_addKeyPressListener(func)
add a key press Listener
function __normalizeEvent(evt)
function neuro_getKeyCodeFromEvent(evt)
Gets the key code from an event i.e.
function neuro_getKeyFromEvent(evt)
Gets the key from an event i.e.