andreasplesch / x_ite_dom

link x_ite to the DOM
http://andreasplesch.github.io/x_ite_dom/index.xhtml
MIT License
6 stars 0 forks source link

Event field callbacks #1

Closed andreasplesch closed 8 years ago

andreasplesch commented 8 years ago

Try that = this

Or context object

andreasplesch commented 8 years ago

Try

CB.bind(undefined, field, sensor)

Function CB (field, sensor, value) {}

andreasplesch commented 8 years ago

Use

new CustomEvent(type, {detail: {value: val, fields: fields}})

andreasplesch commented 8 years ago

https://www.w3.org/TR/DOM-Level-3-Events/#extending-events

event type should be prefixed

x3dCobwebFieldname ? cobwebFieldname ?

probably need to add nodename and def name to avoid namne collisions:

x3dCobwebTouchSensor_isActive

cobwebTouchSensor_isActive

check x3dom's convention: does not dispatch events, just has onoutputchange attribute with callback

+DEF in name, x3d as prefix: x3dTouchSensorTS1_isOver

andreasplesch commented 7 years ago

Thinking more about it, adding the DEF name to the event type may not be ideal.

x3dTouchSensor_isOver

reads pretty well.

The event handler can still figure which TouchSensor the event came from. Let's just add a detail.name property to the event.

In most cases the listener will be attached to the Sensor element. Only listeners above in the hierarchy could capture the event which is probably rare and if there is one it is intentional, for example to capture all touchsensors' (plural) events.