From: Adeel Kazmi Date: Fri, 24 Mar 2017 18:51:32 +0000 (+0000) Subject: Add Back key support to examples which do not have it X-Git-Tag: submit/tizen/20170331.124519^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=06ff0486b4ecc6a5b89d7a50eda92faafb1f6721;p=platform%2Fcore%2Fuifw%2Fdali-demo.git Add Back key support to examples which do not have it Change-Id: Ib36b14b0763130b811ae1f45ce4c631c25d6776c --- diff --git a/examples/focus-integration/focus-integration.cpp b/examples/focus-integration/focus-integration.cpp index 10520b9a..2e80a965 100644 --- a/examples/focus-integration/focus-integration.cpp +++ b/examples/focus-integration/focus-integration.cpp @@ -141,6 +141,9 @@ public: } KeyboardFocusManager::Get().PreFocusChangeSignal().Connect( this, &FocusIntegrationExample::OnPreFocusChange ); + + // Respond to key events + mStage.KeyEventSignal().Connect( this, &FocusIntegrationExample::OnKeyEvent ); } // Callback for KeyboardFocusManager diff --git a/examples/rendering-cube/rendering-cube.cpp b/examples/rendering-cube/rendering-cube.cpp index a42e8324..9d745bd7 100644 --- a/examples/rendering-cube/rendering-cube.cpp +++ b/examples/rendering-cube/rendering-cube.cpp @@ -100,6 +100,9 @@ public: // Respond to a click anywhere on the stage stage.GetRootLayer().TouchSignal().Connect( this, &DrawCubeController::OnTouch ); + + // Respond to key events + stage.KeyEventSignal().Connect( this, &DrawCubeController::OnKeyEvent ); } bool OnTouch( Actor actor, const TouchData& touch ) @@ -109,6 +112,23 @@ public: return true; } + /** + * @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(); + } + } + } + /** * This function creates a cube geometry including texture coordinates. * Also it demonstrates using the indexed draw feature by setting an index array. diff --git a/examples/rendering-line/rendering-line.cpp b/examples/rendering-line/rendering-line.cpp index 70d55cca..d16f8e67 100644 --- a/examples/rendering-line/rendering-line.cpp +++ b/examples/rendering-line/rendering-line.cpp @@ -93,6 +93,9 @@ public: // Respond to a click anywhere on the stage stage.GetRootLayer().TouchSignal().Connect( this, &DrawLineController::OnTouch ); + + // Respond to key events + stage.KeyEventSignal().Connect( this, &DrawLineController::OnKeyEvent ); } bool OnTouch( Actor actor, const TouchData& touch ) @@ -102,6 +105,23 @@ public: return true; } + /** + * @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(); + } + } + } + /** * This function creates a line geometry made of two vertices in order * to draw a diagonal line. diff --git a/examples/rendering-textured-cube/rendering-textured-cube.cpp b/examples/rendering-textured-cube/rendering-textured-cube.cpp index eeda48b9..c2abc592 100644 --- a/examples/rendering-textured-cube/rendering-textured-cube.cpp +++ b/examples/rendering-textured-cube/rendering-textured-cube.cpp @@ -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 ) @@ -115,6 +118,23 @@ public: return true; } + /** + * @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. diff --git a/examples/rendering-triangle/rendering-triangle.cpp b/examples/rendering-triangle/rendering-triangle.cpp index 57233f81..00b4ff1b 100644 --- a/examples/rendering-triangle/rendering-triangle.cpp +++ b/examples/rendering-triangle/rendering-triangle.cpp @@ -93,6 +93,9 @@ public: // Respond to a click anywhere on the stage stage.GetRootLayer().TouchSignal().Connect( this, &DrawTriangleController::OnTouch ); + + // Respond to key events + stage.KeyEventSignal().Connect( this, &DrawTriangleController::OnKeyEvent ); } bool OnTouch( Actor actor, const TouchData& touch ) @@ -102,6 +105,23 @@ public: return true; } + /** + * @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(); + } + } + } + /** * This function creates a triangle geometry made of three vertices in order * to draw a coloured triangle.