[3.0] Updated demos to remove indicator where appropriate
[platform/core/uifw/dali-demo.git] / examples / tilt / tilt-example.cpp
index 0adc72e..230704a 100644 (file)
@@ -59,6 +59,9 @@ public:
     stage.GetRootLayer().TouchSignal().Connect( this, &TiltController::OnTouch );
 
     CreateSensor();
+
+    // Connect signals to allow Back and Escape to exit.
+    stage.KeyEventSignal().Connect( this, &TiltController::OnKeyEvent );
   }
 
   void CreateSensor()
@@ -88,6 +91,21 @@ public:
     mTextLabel.RotateBy(pitchRot);;
   }
 
+  /**
+   * @brief OnKeyEvent signal handler.
+   * @param[in] event The key event information
+   */
+  void OnKeyEvent( const KeyEvent& event )
+  {
+    if( event.state == KeyEvent::Down )
+    {
+      if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
+      {
+        mApplication.Quit();
+      }
+    }
+  }
+
 private:
   Application&  mApplication;
   TiltSensor mTiltSensor;