This example will illustrate how to use the synthetic event creation API.
We'll create an arrow
event that fires in response to the user
pressing the arrow keys (up, down, left, right) and adds a
direction
property to the generated event.
Subscribing to this new event will look like this:
node.on("arrow", onArrowHandler);
node.on("arrow", onArrowHandler);
Support will also be added for delegation, allowing a single subscriber from a node higher up the DOM tree, to listen for the new event emanating from its descendant elements.
containerNode.delegate("arrow", onArrowHandler, ".robot");
containerNode.delegate("arrow", onArrowHandler, ".robot");
Step 1. to the arrow
event.
Step 2. Click on a robot and move it around with the arrow keys.