Keyeventhandler - Adobe ATMOSPHERE User Manual

Table of Contents

Advertisement

268
APPENDIX E
boxEvents.setFilterNoPhysicalModel();
setFilterPhysicalModel(PhysicalModel)
Specifi es that the collision event handler should respond to all collisions for a single physical model.
boxEvents.setFilterPhysicalModel(boxPhysicalModel);
setFilterPhysicalModels(PhysicalModel, PhysicalModel)
Specifi es that the collision event handler should be limited to collisions between two physical models.
boxEvents.setFilterPhysicalModel(boxPhysicalModel, conePhysicalModel);

KeyEventHandler

A KeyEventHandler allows the developer to specify a response when the user presses a key while the focus is on the
rendered window. The recognized key events include keyDown, keyUp, and a catch-all fi lter which recognizes all key
events.
The KeyEventHandler object is more simplifi ed than the MouseEventHandler. Three fi ltering methods exist which
specify the type of event to which the handler should respond, and the fi lters do not require that you pass an object to
the method. The 'setFilterOnKeyDown()' method will cause the handler to respond only when a key is pressed, and
'setFilterOnKeyUp()' will cause a response only when a key is released. The 'setFilterEvent()' method will respond to
all key events.
When a key event occurs, Atmosphere searches the list of user created KeyEventHandlers(with their Filtering
Methods) to determine if the '.OnEvent(keyEvent)' callback should be triggered. If triggered, the 'event' object which
is returned possesses numerous properties about the key event.
Two likely approaches may be used to respond to key events:
Create two event handlers, one which uses the 'setFilterOnKeyDown()' method and the other which uses
'setFilterOnKeyUp()' . When the user presses a key, you may respond differently depending upon which key was
pressed or released. Check the keyEvent returned to determine which key caused the event. A table is provided below
which shows the conversion of key codes to common key names.
Create only a one event handler which uses the 'setFilterEvent()' method, and test event in the same manner as above
to determine the key used.
Your specifi c application will determine the best approach for you.
Global Methods
KeyEventHandler()
Creates a new KeyEventHandler which may be set to process all key events(default), or be limited to down or up
events only.
// create a new handler
myEventHandler = KeyEventHandler();

Advertisement

Table of Contents
loading

Table of Contents