Commit 06ff0486b4ecc6a5b89d7a50eda92faafb1f6721
1 parent
3a831add
Add Back key support to examples which do not have it
Change-Id: Ib36b14b0763130b811ae1f45ce4c631c25d6776c
Showing
5 changed files
with
83 additions
and
0 deletions
examples/focus-integration/focus-integration.cpp
| ... | ... | @@ -141,6 +141,9 @@ public: |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | KeyboardFocusManager::Get().PreFocusChangeSignal().Connect( this, &FocusIntegrationExample::OnPreFocusChange ); |
| 144 | + | |
| 145 | + // Respond to key events | |
| 146 | + mStage.KeyEventSignal().Connect( this, &FocusIntegrationExample::OnKeyEvent ); | |
| 144 | 147 | } |
| 145 | 148 | |
| 146 | 149 | // Callback for KeyboardFocusManager | ... | ... |
examples/rendering-cube/rendering-cube.cpp
| ... | ... | @@ -100,6 +100,9 @@ public: |
| 100 | 100 | |
| 101 | 101 | // Respond to a click anywhere on the stage |
| 102 | 102 | stage.GetRootLayer().TouchSignal().Connect( this, &DrawCubeController::OnTouch ); |
| 103 | + | |
| 104 | + // Respond to key events | |
| 105 | + stage.KeyEventSignal().Connect( this, &DrawCubeController::OnKeyEvent ); | |
| 103 | 106 | } |
| 104 | 107 | |
| 105 | 108 | bool OnTouch( Actor actor, const TouchData& touch ) |
| ... | ... | @@ -110,6 +113,23 @@ public: |
| 110 | 113 | } |
| 111 | 114 | |
| 112 | 115 | /** |
| 116 | + * @brief Called when any key event is received | |
| 117 | + * | |
| 118 | + * Will use this to quit the application if Back or the Escape key is received | |
| 119 | + * @param[in] event The key event information | |
| 120 | + */ | |
| 121 | + void OnKeyEvent( const KeyEvent& event ) | |
| 122 | + { | |
| 123 | + if( event.state == KeyEvent::Down ) | |
| 124 | + { | |
| 125 | + if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) | |
| 126 | + { | |
| 127 | + mApplication.Quit(); | |
| 128 | + } | |
| 129 | + } | |
| 130 | + } | |
| 131 | + | |
| 132 | + /** | |
| 113 | 133 | * This function creates a cube geometry including texture coordinates. |
| 114 | 134 | * Also it demonstrates using the indexed draw feature by setting an index array. |
| 115 | 135 | */ | ... | ... |
examples/rendering-line/rendering-line.cpp
| ... | ... | @@ -93,6 +93,9 @@ public: |
| 93 | 93 | |
| 94 | 94 | // Respond to a click anywhere on the stage |
| 95 | 95 | stage.GetRootLayer().TouchSignal().Connect( this, &DrawLineController::OnTouch ); |
| 96 | + | |
| 97 | + // Respond to key events | |
| 98 | + stage.KeyEventSignal().Connect( this, &DrawLineController::OnKeyEvent ); | |
| 96 | 99 | } |
| 97 | 100 | |
| 98 | 101 | bool OnTouch( Actor actor, const TouchData& touch ) |
| ... | ... | @@ -103,6 +106,23 @@ public: |
| 103 | 106 | } |
| 104 | 107 | |
| 105 | 108 | /** |
| 109 | + * @brief Called when any key event is received | |
| 110 | + * | |
| 111 | + * Will use this to quit the application if Back or the Escape key is received | |
| 112 | + * @param[in] event The key event information | |
| 113 | + */ | |
| 114 | + void OnKeyEvent( const KeyEvent& event ) | |
| 115 | + { | |
| 116 | + if( event.state == KeyEvent::Down ) | |
| 117 | + { | |
| 118 | + if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) | |
| 119 | + { | |
| 120 | + mApplication.Quit(); | |
| 121 | + } | |
| 122 | + } | |
| 123 | + } | |
| 124 | + | |
| 125 | + /** | |
| 106 | 126 | * This function creates a line geometry made of two vertices in order |
| 107 | 127 | * to draw a diagonal line. |
| 108 | 128 | */ | ... | ... |
examples/rendering-textured-cube/rendering-textured-cube.cpp
| ... | ... | @@ -106,6 +106,9 @@ public: |
| 106 | 106 | |
| 107 | 107 | // Respond to a click anywhere on the stage |
| 108 | 108 | stage.GetRootLayer().TouchSignal().Connect( this, &TexturedCubeController::OnTouch ); |
| 109 | + | |
| 110 | + // Respond to key events | |
| 111 | + stage.KeyEventSignal().Connect( this, &TexturedCubeController::OnKeyEvent ); | |
| 109 | 112 | } |
| 110 | 113 | |
| 111 | 114 | bool OnTouch( Actor actor, const TouchData& touch ) |
| ... | ... | @@ -116,6 +119,23 @@ public: |
| 116 | 119 | } |
| 117 | 120 | |
| 118 | 121 | /** |
| 122 | + * @brief Called when any key event is received | |
| 123 | + * | |
| 124 | + * Will use this to quit the application if Back or the Escape key is received | |
| 125 | + * @param[in] event The key event information | |
| 126 | + */ | |
| 127 | + void OnKeyEvent( const KeyEvent& event ) | |
| 128 | + { | |
| 129 | + if( event.state == KeyEvent::Down ) | |
| 130 | + { | |
| 131 | + if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) | |
| 132 | + { | |
| 133 | + mApplication.Quit(); | |
| 134 | + } | |
| 135 | + } | |
| 136 | + } | |
| 137 | + | |
| 138 | + /** | |
| 119 | 139 | * @brief CreateCubeGeometry |
| 120 | 140 | * This function creates a cube geometry including texture coordinates. |
| 121 | 141 | * Also it demonstrates using the indexed draw feature by setting an index array. | ... | ... |
examples/rendering-triangle/rendering-triangle.cpp
| ... | ... | @@ -93,6 +93,9 @@ public: |
| 93 | 93 | |
| 94 | 94 | // Respond to a click anywhere on the stage |
| 95 | 95 | stage.GetRootLayer().TouchSignal().Connect( this, &DrawTriangleController::OnTouch ); |
| 96 | + | |
| 97 | + // Respond to key events | |
| 98 | + stage.KeyEventSignal().Connect( this, &DrawTriangleController::OnKeyEvent ); | |
| 96 | 99 | } |
| 97 | 100 | |
| 98 | 101 | bool OnTouch( Actor actor, const TouchData& touch ) |
| ... | ... | @@ -103,6 +106,23 @@ public: |
| 103 | 106 | } |
| 104 | 107 | |
| 105 | 108 | /** |
| 109 | + * @brief Called when any key event is received | |
| 110 | + * | |
| 111 | + * Will use this to quit the application if Back or the Escape key is received | |
| 112 | + * @param[in] event The key event information | |
| 113 | + */ | |
| 114 | + void OnKeyEvent( const KeyEvent& event ) | |
| 115 | + { | |
| 116 | + if( event.state == KeyEvent::Down ) | |
| 117 | + { | |
| 118 | + if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) | |
| 119 | + { | |
| 120 | + mApplication.Quit(); | |
| 121 | + } | |
| 122 | + } | |
| 123 | + } | |
| 124 | + | |
| 125 | + /** | |
| 106 | 126 | * This function creates a triangle geometry made of three vertices in order |
| 107 | 127 | * to draw a coloured triangle. |
| 108 | 128 | */ | ... | ... |