Class Index | File Index

Classes


Class R.engine.Events

A static object for uniformly handling events within all browser platforms. The event engine is an abstraction of the jQuery event system. Methods are provided for adding and removing events in a programmatic way. Additionally the engine has key codes for common keys which aren't part of the letters or numbers.

While the engine provides a low-level way to attach events, when working with game objects methods are provided to manage events better than with the engine itself.

Adding an event:

var t = $(".myElement");
R.engine.Events.setHandler(t, "click", function(event) {
   MyObject.evtHandler();
});

Defined in: events.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Field Summary
Field Attributes Field Name and Description
 
Constant for the "Backspace"
 
Constant for the "Delete" key
 
Constant for the "Down" key
 
Constant for the "End" key
 
Constant for the "Enter" key
 
Constant for the "F1" key
 
Constant for the "F10" key
 
Constant for the "F11" key
 
Constant for the "F12" key
 
Constant for the "F2" key
 
Constant for the "F3" key
 
Constant for the "F4" key
 
Constant for the "F5" key
 
Constant for the "F6" key
 
Constant for the "F7" key
 
Constant for the "F8" key
 
Constant for the "F9" key
 
Constant for the "Home" key
 
Constant for the "Minus" key
 
Constant for the "Plus" key
 
Constant for the "Left" key
 
Constant for the "Context Menu" key (Windows)
 
Constant for the "RIGHT" key
 
Constant for the "Space" key
 
Constant for the "Tab" key
 
Constant for the "Up" key
 
Constant for the "Windows" key (Windows)
 
Left mouse button.
 
Middle mouse button.
 
No mouse button pressed.
 
Right mouse button.
Method Summary
Method Attributes Method Name and Description
<static>  
R.engine.Events.clearHandler(target, name, handler)
Clear an event handler that was previously assigned to the target.
 
isKey(eventObj, keyStr)
Returns true if the key pressed is either the lower or upper case version of the key specified in "keyStr".
<static>  
R.engine.Events.keyCodeForChar(charStr, literal)
Get the key code for the provided character.
<static>  
R.engine.Events.setHandler(target, data, name, handler)
Set an event handler on a target.
Class Detail
R.engine.Events()
See:
R.engine.BaseObject#addEvent
R.engine.BaseObject#removeEvent
Field Detail
KEYCODE_BACKSPACE
Constant for the "Backspace"

KEYCODE_DELETE
Constant for the "Delete" key

KEYCODE_DOWN_ARROW
Constant for the "Down" key

KEYCODE_END
Constant for the "End" key

KEYCODE_ENTER
Constant for the "Enter" key

KEYCODE_F1
Constant for the "F1" key

KEYCODE_F10
Constant for the "F10" key

KEYCODE_F11
Constant for the "F11" key

KEYCODE_F12
Constant for the "F12" key

KEYCODE_F2
Constant for the "F2" key

KEYCODE_F3
Constant for the "F3" key

KEYCODE_F4
Constant for the "F4" key

KEYCODE_F5
Constant for the "F5" key

KEYCODE_F6
Constant for the "F6" key

KEYCODE_F7
Constant for the "F7" key

KEYCODE_F8
Constant for the "F8" key

KEYCODE_F9
Constant for the "F9" key

KEYCODE_HOME
Constant for the "Home" key

KEYCODE_KEYPAD_MINUS
Constant for the "Minus" key

KEYCODE_KEYPAD_PLUS
Constant for the "Plus" key

KEYCODE_LEFT_ARROW
Constant for the "Left" key

KEYCODE_MENU
Constant for the "Context Menu" key (Windows)

KEYCODE_RIGHT_ARROW
Constant for the "RIGHT" key

KEYCODE_SPACE
Constant for the "Space" key

KEYCODE_TAB
Constant for the "Tab" key

KEYCODE_UP_ARROW
Constant for the "Up" key

KEYCODE_WINDOW
Constant for the "Windows" key (Windows)

MOUSE_LEFT_BUTTON
Left mouse button.

MOUSE_MIDDLE_BUTTON
Middle mouse button.

MOUSE_NO_BUTTON
No mouse button pressed.

MOUSE_RIGHT_BUTTON
Right mouse button.
Method Detail
<static> R.engine.Events.clearHandler(target, name, handler)
Clear an event handler that was previously assigned to the target. If no specific handler is assigned, all event handlers will be removed from the target.
Parameters:
target
{String/jQuery} The target for the event. This should either be a CSS selector, or a jQuery object.
name
{String} The event to handle. ie: "click" or "mouseover"
handler
{Function} The handler function to unassign from the target

isKey(eventObj, keyStr)
Returns true if the key pressed is either the lower or upper case version of the key specified in "keyStr".
Parameters:
eventObj
keyStr

<static> {Number} R.engine.Events.keyCodeForChar(charStr, literal)
Get the key code for the provided character. The value returned will be for the uppercase key value, unless the second argument is set to true which will return the exact key code for the provided character.
Parameters:
charStr
{String} A single character to get the key code for
literal Optional
{Boolean} true to return the literal code without first converting the character to lower case.
Returns:
{Number} The key code for the given character

<static> R.engine.Events.setHandler(target, data, name, handler)
Set an event handler on a target. The handler function will be called whenever the event occurs.
Parameters:
target
{String/jQuery} The target for the event. This should either be a CSS selector, or a jQuery object.
data Optional
{Array} Optional data to pass to the handler when it is invoked.
name
{String} The event to handle. ie: "click" or "mouseover"
handler
{Function} The handler function to assign to the target

Documentation generated by JsDoc Toolkit 2.4.0 on Mon Mar 18 2013 16:09:18 GMT-0400 (EDT)