Commit 33c47f515d3ebd0c91116c6c1fd8c473e70ca0a8
1 parent
c782943e
Added key event handling to image-view-example
To allow quitting example with escape or back key Change-Id: Icaa30d4991ee2f65e8c10e4fc136f52de05168cd
Showing
1 changed file
with
16 additions
and
0 deletions
examples/image-view/image-view-example.cpp
| ... | ... | @@ -141,6 +141,8 @@ class ImageViewController: public ConnectionTracker |
| 141 | 141 | buttonsTable.AddChild( button3, Toolkit::TableView::CellPosition( 2, 0 ) ); |
| 142 | 142 | |
| 143 | 143 | mContentLayer.Add(buttonsTable); |
| 144 | + | |
| 145 | + Stage::GetCurrent().KeyEventSignal().Connect(this, &ImageViewController::OnKeyEvent); | |
| 144 | 146 | } |
| 145 | 147 | |
| 146 | 148 | private: |
| ... | ... | @@ -220,6 +222,20 @@ private: |
| 220 | 222 | return true; |
| 221 | 223 | } |
| 222 | 224 | |
| 225 | + /** | |
| 226 | + * Main key event handler | |
| 227 | + */ | |
| 228 | + void OnKeyEvent(const KeyEvent& event) | |
| 229 | + { | |
| 230 | + if(event.state == KeyEvent::Down) | |
| 231 | + { | |
| 232 | + if( IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK ) ) | |
| 233 | + { | |
| 234 | + mApplication.Quit(); | |
| 235 | + } | |
| 236 | + } | |
| 237 | + } | |
| 238 | + | |
| 223 | 239 | private: |
| 224 | 240 | Application& mApplication; |
| 225 | 241 | ... | ... |