Dali 3D User Interface Engine
multi-touch-guide

Multi-Touch Events

Touch events are received via signals.

For C++ API see Dali::Actor::TouchedSignal() and Dali::Actor::HoveredSignal() for more details.

For JavaScript use actor.connect( "touched", myCallback ) and actor.connect("hovered", myCallback );

Hit Testing Rules Summary:

Hit Test Algorithm:

HIT-TEST-WITHIN-LAYER( ACTOR )
{
// Only hit-test the actor and its children if it is sensitive and visible
IF ( ACTOR-IS-SENSITIVE &&
ACTOR-IS-VISIBLE )
{
// Depth-first traversal within current layer, visiting parent first
// Check whether current actor should be hit-tested
IF ( TOUCH-SIGNAL-NOT-EMPTY &&
ACTOR-HAS-NON-ZERO-SIZE &&
ACTOR-WORLD-COLOR-IS-NOT-TRANSPARENT )
{
// Hit-test current actor
IF ( ACTOR-HIT )
{
IF ( ACTOR-IS-OVERLAY || ( DISTANCE-TO-ACTOR < DISTANCE-TO-LAST-HIT-ACTOR ) )
{
// The current actor is the closest actor that was underneath the touch
LAST-HIT-ACTOR = CURRENT-ACTOR
}
}
}
// Keep checking children, in case we hit something closer
FOR-EACH CHILD (in order)
{
IF ( CHILD-IS-NOT-A-LAYER )
{
// Continue traversal for this child's sub-tree
HIT-TEST-WITHIN-LAYER ( CHILD )
}
// else we skip hit-testing the child's sub-tree altogether
}
}
}
1
/ \
/ \
2 5
/ \ \
/ \ \
3 4 6
Hit Priority of above Actor tree (all overlays): 1 - Lowest. 6 - Highest.

Touch Event Delivery:

EMIT-TOUCH-SIGNAL( ACTOR )
{
IF ( TOUCH-SIGNAL-NOT-EMPTY )
{
// Only do the emission if touch signal of actor has connections.
CONSUMED = TOUCHED-SIGNAL( TOUCH-EVENT )
}
IF ( NOT-CONSUMED )
{
// If event is not consumed then deliver it to the parent unless we reach the root actor
IF ( ACTOR-PARENT )
{
EMIT-TOUCH-SIGNAL( ACTOR-PARENT )
}
}
}
Dali Docs Home
Read more about Dali