Fixed crash for stage touched signal callback in JavaScript
[platform/core/uifw/dali-toolkit.git] / plugins / dali-script-v8 / src / events / event-object-generator.cpp
index f41f5ac..e90fe8c 100644 (file)
@@ -118,8 +118,11 @@ v8::Local<v8::Object> CreateTouchPoint( v8::Isolate* isolate, const TouchPoint&
   // set state
   pointObject->Set( v8::String::NewFromUtf8( isolate, "state"), v8::String::NewFromUtf8( isolate, GetTouchPointStateName(touchPoint.state)));
 
-  // set the hit actor
-  pointObject->Set( v8::String::NewFromUtf8( isolate, "hitActor"), ActorWrapper::WrapActor(isolate, touchPoint.hitActor ));
+  if(touchPoint.hitActor)
+  {
+    // set the hit actor
+    pointObject->Set( v8::String::NewFromUtf8( isolate, "hitActor"), ActorWrapper::WrapActor(isolate, touchPoint.hitActor ));
+  }
 
   // Think about changing these Vector 2 from wrapped objects to JavaScript objects...
 
@@ -231,23 +234,28 @@ v8::Handle<v8::Object> EventObjectGenerator::CreateHoverEvent( v8::Isolate* isol
   return handleScope.Escape( hoverObject );
 }
 
-v8::Handle<v8::Object> EventObjectGenerator::CreateMouseWheelEvent( v8::Isolate* isolate, const MouseWheelEvent& wheelEvent)
+v8::Handle<v8::Object> EventObjectGenerator::CreateWheelEvent( v8::Isolate* isolate, const WheelEvent& wheelEvent)
 {
-  //  we are creating a mouse wheel event object that looks like this
+  //  we are creating a wheel event object that looks like this
   //
+  //  event.type = "mouseWheel" or "customWheel" type of the wheel event
   //  event.direction = "vertical" or "horizontal" direction the wheel is being rolled
   //  event.shiftPressed       = boolean, shift key is held
   //  event.ctrlPressed        = boolean, ctrl key is held
   //  event.altPressed     = boolean, alt key is held
   //  event.keyModifiers = bitmask of keys pressed
   //  event.point {x,y}    = The co-ordinates of the mouse cursor relative to the top-left of the screen when the wheel is being rolled.
-  //  event.rolled          = offset of mouse wheel rolling, positive = rolling down, negative = rolling up
+  //  event.rolled          = offset of wheel rolling, positive = rolling down or clockwise, negative = rolling up or counter-clockwise
   //  event.timestamp    = The time (in ms) that the touch event occurred
 
   v8::EscapableHandleScope handleScope( isolate );
 
   v8::Local<v8::Object> wheelObject = v8::Object::New( isolate );
 
+  // Set the type
+  std::string type = wheelEvent.type ? "mouseWheel" : "customWheel";
+  wheelObject->Set( v8::String::NewFromUtf8( isolate, "type" ), v8::String::NewFromUtf8( isolate, type.c_str() ) );
+
   // Set the direction
   std::string direction = wheelEvent.direction ? "vertical" : "horizontal";
   wheelObject->Set( v8::String::NewFromUtf8( isolate, "direction" ), v8::String::NewFromUtf8( isolate, direction.c_str() ) );