[dali_1.2.33] Merge branch 'devel/master'
[platform/core/uifw/dali-demo.git] / examples / rendering-textured-cube / rendering-textured-cube.cpp
index eeda48b..c2abc59 100644 (file)
@@ -106,6 +106,9 @@ public:
 
     // Respond to a click anywhere on the stage
     stage.GetRootLayer().TouchSignal().Connect( this, &TexturedCubeController::OnTouch );
+
+    // Respond to key events
+    stage.KeyEventSignal().Connect( this, &TexturedCubeController::OnKeyEvent );
   }
 
   bool OnTouch( Actor actor, const TouchData& touch )
@@ -116,6 +119,23 @@ public:
   }
 
   /**
+   * @brief Called when any key event is received
+   *
+   * Will use this to quit the application if Back or the Escape key is received
+   * @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();
+      }
+    }
+  }
+
+  /**
    * @brief CreateCubeGeometry
    * This function creates a cube geometry including texture coordinates.
    * Also it demonstrates using the indexed draw feature by setting an index array.