| Name | Description | Parameters passed to call back |
|-----------------|----------------------------------------|--------------------------|
-|touched | touch event | (actor, touchEvent ) |
+|touch | touch | (actor, touchData ) |
|hovered | mouse or pointer hovering over actor | (actor, hoverEvent) |
|mouseWheelEvent | mouse wheel events | (actor, wheelEvent) |
|onStage | actor has been moved on stage | (actor) |
#### Touch event
Used to detect multiple touch events on the actor. The state of each touch point can be:
-+ "down" = touch down
-+ "up" = Touch up
-+ "motion" = Finger dragged or hovered
-+ "leave" = Leave the boundary of an actor
-+ "stationary" = No change from last event. Useful when a multi-point event occurs where
-all points are sent but indicates that this particular point has not changed since the last time
-+ "interrupted" = A system event has occurred which has interrupted the touch or hover event sequence
++ "DOWN" = touch down
++ "UP" = Touch up
++ "MOTION" = Finger dragged or hovered
++ "LEAVE" = Leave the boundary of an actor
++ "STATIONARY" = No change from last event. Useful when a multi-point event occurs where
+ all points are sent but indicates that this particular point has not changed
+ since the last time
++ "INTERRUPTED" = A system event has occurred which has interrupted the touch or hover event sequence
```
-touchEvent = {
+touchData = {
pointCount: int, // number of points touched ( multi-touch )
time: int, // The time in milliseconds that the touch event occurred.
- points = [ touchPoints ], // array of TouchPoints, to support
+ points = [ Points ], // array of Points
- TouchPoint = {
-
- "deviceId" : int, // Each touch point has a unique device ID
- "state" : string, // touch state ="down,up,motion,leave,stationary, interrupted }
- "sourceActor" : actor, // the actor that is emitting the callback (the actor that is hit maybe a child of it)
- "hitActor" : actor, // actor that was hit
- "local" : {x,y}, // co-ordinates of top left of hit actor (local.x, local.y)
- "screen" : {x,y} // co-ordinates of top left of hit actor (screen.x, screen.y)
- }
+ Point = {
+ "deviceId" : int, // Each touch point has a unique device ID
+ "state" : string, // touch state ="DOWN","UP","MOTION","LEAVE","STATIONARY","INTERRUPTED"
+ "sourceActor" : actor, // the actor that is emitting the callback (the actor that is hit maybe a child of it)
+ "hitActor" : actor, // actor that was hit
+ "local" : {x,y}, // co-ordinates of top left of hit actor (local.x, local.y)
+ "screen" : {x,y}, // co-ordinates of top left of hit actor (screen.x, screen.y)
+ "radius" : float, // radius of the press point (average of both the horizontal & vertical radii)
+ "ellipseRadius" : {x,y}, // both the horizontal and the vertical radii of the press point
+ "pressure" : float, // the touch pressure
+ "angle" : float // angle of the press point relative to the Y-Axis (in degrees)
+ }
}
-function OnPressed( actor, touchEvent )
+function onPressed( actor, touchData )
{
- var firstPoint = touchEvent.points[0];
- log("first touch point = " + firstPoint.screen.x + "," +firstPoint.screen.x + "actor= "+firstPoint.hitActor );
+ var firstPoint = touchData.points[0];
+ log("first touch point = " + firstPoint.screen.x + "," + firstPoint.screen.x + "actor= " + firstPoint.hitActor );
var anim = new dali.Animation( 4 );
var rotation = new dali.Rotation( 90, 0, 0 ); // pitch, yaw, roll
}
// connect to touch events
-myActor.on( "touched", onPressed );
+myActor.on( "touch", onPressed );
```
points[] // array of TouchPoints
TouchPoint = {
- // See touchEvent TouchPoint object
+ "deviceId" : int, // Each touch point has a unique device ID
+ "state" : string, // touch state ="down,up,motion,leave,stationary, interrupted }
+ "sourceActor" : actor, // the actor that is emitting the callback (the actor that is hit maybe a child of it)
+ "hitActor" : actor, // actor that was hit
+ "local" : {x,y}, // co-ordinates of top left of hit actor (local.x, local.y)
+ "screen" : {x,y} // co-ordinates of top left of hit actor (screen.x, screen.y)
}
}
```
/**
* Actors sensitive flag
- * brief Sets whether an actor should emit touch event signals; @see SignalTouched().
+ * brief Sets whether an actor should emit touch event signals; @see SignalTouch().
*
- * An actor is sensitive by default, which means that as soon as an application connects to the SignalTouched(),
+ * An actor is sensitive by default, which means that as soon as an application connects to the SignalTouch(),
* the touch event signal will be emitted.
*
* If the application wishes to temporarily disable the touch event signal emission, then they can do so by calling
namespace
{
-struct PointState
+struct TouchDataPointState
+{
+ PointState::Type state;
+ const char* name;
+};
+
+const TouchDataPointState TouchDataPointStateLookup[]=
+{
+ { PointState::DOWN, "DOWN" },
+ { PointState::UP, "UP" },
+ { PointState::MOTION, "MOTION" },
+ { PointState::LEAVE, "LEAVE" },
+ { PointState::STATIONARY, "STATIONARY" },
+ { PointState::INTERRUPTED, "INTERRUPT" },
+ { PointState::STARTED, "STARTED" },
+ { PointState::FINISHED, "FINISHED" },
+};
+
+const unsigned int TouchDataPointStateLookupCount = sizeof(TouchDataPointStateLookup)/sizeof(TouchDataPointStateLookup[0]);
+
+struct TouchPointState
{
TouchPoint::State state;
const char* name;
};
-const PointState PointStateLookup[]=
+const TouchPointState PointStateLookup[]=
{
{ TouchPoint::Down, "down" }, /**< Screen touched */
{ TouchPoint::Up, "up" }, /**< Touch stopped */
const unsigned int GestureStateLookupCount = sizeof(GestureStateLookup)/sizeof(GestureStateLookup[0]);
+const char* GetTouchDataPointStateName( PointState::Type state )
+{
+ // could use the enum as index, but dali-core may change, so for now just do a lookup
+ for( unsigned int i = 0; i < TouchDataPointStateLookupCount; i++ )
+ {
+ if( TouchDataPointStateLookup[i].state == state )
+ {
+ return TouchDataPointStateLookup[i].name;
+ }
+ }
+ return "error point state not found";
+}
+
const char* GetTouchPointStateName( TouchPoint::State state )
{
// could use the enum as index, but dali-core may change, so for now just do a lookup
} // un-named namespace
-v8::Handle<v8::Object> EventObjectGenerator::CreateTouchEvent( v8::Isolate* isolate, const TouchEvent& touchEvent)
+v8::Handle<v8::Object> EventObjectGenerator::CreateTouchData( v8::Isolate* isolate, const TouchData& touch )
{
// we are creating a touch event object that looks like this
//
// event.pointCount = points touched
// event.time = The time (in ms) that the touch event occurred.
- // event.point[] = array of TouchPoints
+ // event.point[] = array of Points
//
- // A TouchPoint =
+ // A Point =
// { "deviceId", int } Each touch point has a unique device ID
// { "state", string } touch state ="Down,Up,Motion,Leave,Stationary, Interrupted }
// { "sourceActor", actor } the actor that is emitting the callback (the actor that is hit maybe a child of it)
// { "hitActor", actor } actor that was hit
// { "local", {x,y} } co-ordinates of top left of hit actor
// { "screen", {x,y} } co-ordinates of top left of hit actor
+ // { "radius", float } radius of the press point (average of both the horizontal & vertical radii)
+ // { "ellipseRadius", {x,y} } both the horizontal and the vertical radii of the press point
+ // { "pressure", float } the touch pressure
+ // { "angle", float } angle of the press point relative to the Y-Axis
//
v8::EscapableHandleScope handleScope( isolate );
v8::Local<v8::Object> touchObject = v8::Object::New( isolate );
// Set the pointCount
- touchObject->Set( v8::String::NewFromUtf8( isolate, "pointCount" ), v8::Integer::New( isolate, touchEvent.GetPointCount() ) );
+ touchObject->Set( v8::String::NewFromUtf8( isolate, "pointCount" ), v8::Integer::New( isolate, touch.GetPointCount() ) );
// Set the time
- touchObject->Set( v8::String::NewFromUtf8( isolate, "time" ), v8::Number::New( isolate, touchEvent.time ) );
+ touchObject->Set( v8::String::NewFromUtf8( isolate, "time" ), v8::Number::New( isolate, touch.GetTime() ) );
// Set the emitting actor
// touchObject->Set( v8::String::NewFromUtf8( isolate, "sourceActor" ), ActorWrapper::WrapActor(isolate, emittingActor));
// Create the array of touch points
- v8::Local < v8::Array > pointArrayObject = v8::Array::New( isolate, touchEvent.GetPointCount() );
- for( unsigned int i = 0 ; i < touchEvent.GetPointCount() ; ++i )
+ v8::Local < v8::Array > pointArrayObject = v8::Array::New( isolate, touch.GetPointCount() );
+ for( unsigned int i = 0 ; i < touch.GetPointCount() ; ++i )
{
- v8::Local < v8::Object > pointObject = CreateTouchPoint( isolate, touchEvent.points[i] );
+ v8::Local<v8::Object> pointObject = v8::Object::New( isolate );
+
+ // set device id
+ pointObject->Set( v8::String::NewFromUtf8( isolate, "deviceId" ), v8::Integer::New( isolate, touch.GetDeviceId( i ) ) );
+
+ // set state
+ pointObject->Set( v8::String::NewFromUtf8( isolate, "state" ), v8::String::NewFromUtf8( isolate, GetTouchDataPointStateName( touch.GetState( i ) ) ) );
+
+ Actor hitActor = touch.GetHitActor( i );
+ if( hitActor )
+ {
+ // set the hit actor
+ pointObject->Set( v8::String::NewFromUtf8( isolate, "hitActor" ), ActorWrapper::WrapActor( isolate, hitActor ) );
+ }
+
+ // set the local co-ordinates
+ const Vector2& local = touch.GetLocalPosition( i );
+ v8::Local<v8::Object> localPointObject = v8::Object::New( isolate );
+ localPointObject->Set( v8::String::NewFromUtf8( isolate, "x" ), v8::Integer::New( isolate, local.x ) );
+ localPointObject->Set( v8::String::NewFromUtf8( isolate, "y" ), v8::Integer::New( isolate, local.y ) );
+ pointObject->Set( v8::String::NewFromUtf8( isolate, "local" ), localPointObject );
+
+ // set the screen co-ordinates
+ const Vector2& screen = touch.GetScreenPosition( i );
+ v8::Local<v8::Object> screenPointObject = v8::Object::New( isolate );
+ screenPointObject->Set( v8::String::NewFromUtf8( isolate, "x" ), v8::Integer::New( isolate, screen.x ) );
+ screenPointObject->Set( v8::String::NewFromUtf8( isolate, "y" ), v8::Integer::New( isolate, screen.y ) );
+ pointObject->Set( v8::String::NewFromUtf8( isolate, "screen" ), screenPointObject );
+
+ // set the radius
+ pointObject->Set( v8::String::NewFromUtf8( isolate, "radius" ), v8::Integer::New( isolate, touch.GetRadius( i ) ) );
+
+ // set the ellipse Radius
+ const Vector2& ellipse = touch.GetEllipseRadius( i );
+ v8::Local<v8::Object> ellipseObject = v8::Object::New( isolate );
+ ellipseObject->Set( v8::String::NewFromUtf8( isolate, "x" ), v8::Integer::New( isolate, ellipse.x ) );
+ ellipseObject->Set( v8::String::NewFromUtf8( isolate, "y" ), v8::Integer::New( isolate, ellipse.y ) );
+ pointObject->Set( v8::String::NewFromUtf8( isolate, "ellipseRadius" ), ellipseObject );
+
+ // set the pressure
+ pointObject->Set( v8::String::NewFromUtf8( isolate, "pressure" ), v8::Integer::New( isolate, touch.GetPressure( i ) ) );
+
+ // set the angle
+ pointObject->Set( v8::String::NewFromUtf8( isolate, "angle" ), v8::Integer::New( isolate, touch.GetAngle( i ).degree ) );
+
+ // add the point
pointArrayObject->Set( v8::Number::New( isolate, i ), pointObject );
}
// EXTERNAL INCLUDES
#include <v8.h>
-#include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/events/touch-data.h>
#include <dali/public-api/events/hover-event.h>
#include <dali/public-api/events/wheel-event.h>
#include <dali/public-api/events/key-event.h>
namespace EventObjectGenerator
{
- v8::Handle<v8::Object> CreateTouchEvent( v8::Isolate* isolate, const TouchEvent& touchEvent);
+ v8::Handle<v8::Object> CreateTouchData( v8::Isolate* isolate, const TouchData& touch );
v8::Handle<v8::Object> CreateHoverEvent( v8::Isolate* isolate, const HoverEvent& hoverEvent);
v8::Handle<v8::Object> CreateWheelEvent( v8::Isolate* isolate, const WheelEvent& wheelEvent);
v8::Handle<v8::Object> CreateKeyEvent( v8::Isolate* isolate, const KeyEvent& keyEvent);
{
returnValue = PropertyValueWrapper::WrapDaliProperty( isolate, value.Get<Vector3>() );
}
- else if( typeInfo == typeid( Dali::TouchEvent ) )
+ else if( typeInfo == typeid( Dali::TouchData ) )
{
- returnValue = EventObjectGenerator::CreateTouchEvent( isolate, value.Get<TouchEvent>() );
+ returnValue = EventObjectGenerator::CreateTouchData( isolate, value.Get<TouchData>() );
}
else if( typeInfo == typeid( Dali::HoverEvent ) )
{
#include <dali/public-api/events/pan-gesture-detector.h>
#include <dali/public-api/object/any.h>
#include <dali/public-api/images/image.h>
-#include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/events/touch-data.h>
#include <dali/public-api/events/hover-event.h>
#include <dali/public-api/events/wheel-event.h>
#include <dali/public-api/events/key-event.h>
namespace // un-named namespace
{
-const char* const SIGNAL_TOUCHED = "touched";
+const char* const SIGNAL_TOUCH = "touch";
const char* const SIGNAL_HOVERED = "hovered";
const char* const SIGNAL_WHEEL_EVENT = "wheelEvent";
const char* const SIGNAL_ON_STAGE = "onStage";
const char* const STAGE_SIGNAL_KEY_EVENT = "keyEvent";
const char* const STAGE_SIGNAL_EVENT_PROCESSING_FINISHED = "eventProcessingFinished";
-const char* const STAGE_SIGNAL_TOUCHED = "touched";
+const char* const STAGE_SIGNAL_TOUCH = "touch";
const char* const SIGNAL_IMAGE_LOADING_FINISHED = "imageLoadingFinished";
const char* const SIGNAL_IMAGE_UPLOADED = "uploaded";
mActor(actor)
{
}
- bool OnTouch( Actor actor, const TouchEvent& event)
+ bool OnTouch( Actor actor, const TouchData& touch )
{
std::vector< Dali::Any > arguments; // Dali::Vector considers Dali::Any to be a non trivial type so won't compile
Dali::Any returnValue(false);
arguments.push_back( actor );
- arguments.push_back( event );
+ arguments.push_back( touch );
CallJavaScript( returnValue, arguments );
bool ret;
returnValue.Get(ret);
Dali::Any returnValue; //no return
CallJavaScript( returnValue, arguments );
}
- void TouchedSignal( const TouchEvent& touchEvent)
+ void TouchSignal( const TouchData& touch )
{
std::vector< Dali::Any > arguments;
Dali::Any returnValue; //no return
- arguments.push_back( touchEvent );
+ arguments.push_back( touch );
CallJavaScript( returnValue, arguments );
}
};
ActorCallback* callback =new ActorCallback( isolate, javaScriptCallback, signalName, actor );
- if( strcmp( signalName.c_str(), SIGNAL_TOUCHED ) == 0 )
+ if( strcmp( signalName.c_str(), SIGNAL_TOUCH ) == 0 )
{
- actor.TouchedSignal().Connect( callback, &ActorCallback::OnTouch );
+ actor.TouchSignal().Connect( callback, &ActorCallback::OnTouch );
}
else if( strcmp( signalName.c_str(), SIGNAL_HOVERED ) == 0 )
{
{
stage.EventProcessingFinishedSignal().Connect( callback, &StageCallback::EventProcessingFinishedSignal );
}
- else if (strcmp( signalName.c_str(), STAGE_SIGNAL_TOUCHED ) == 0 )
+ else if (strcmp( signalName.c_str(), STAGE_SIGNAL_TOUCH ) == 0 )
{
- stage.TouchedSignal().Connect( callback, &StageCallback::TouchedSignal );
+ stage.TouchSignal().Connect( callback, &StageCallback::TouchSignal );
}
else
{
// first paramter = signal to connect to
// Second parameter = function ( to run )
// args.This() = myActor
- // e.g. myActor.Connect("touched", myJavaScriptActorTouched );
+ // e.g. myActor.Connect("touch", myJavaScriptActorTouched );
// Inside Callback on myJavaScriptActorTouched
- // myActor.Disconnect("touched", myJavaScriptActorTouched );
+ // myActor.Disconnect("touch", myJavaScriptActorTouched );
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope handleScope( isolate );