Back/Escape key callback for Simple Text Field test. 81/203481/1
authorVictor Cebollada <v.cebollada@samsung.com>
Mon, 15 Apr 2019 06:43:39 +0000 (07:43 +0100)
committerVictor Cebollada <v.cebollada@samsung.com>
Mon, 15 Apr 2019 06:46:25 +0000 (07:46 +0100)
* The test can be closed now.

Change-Id: I2f38efe998deb505d67dc969f7c6f16d338a2fc5
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
examples/simple-text-field/simple-text-field.cpp

index d96906b..3516e77 100644 (file)
@@ -53,6 +53,7 @@ public:
   void Create( Application& application )
   {
     Stage stage = Stage::GetCurrent();
+    stage.KeyEventSignal().Connect(this, &SimpleTextFieldExample::OnKeyEvent);
     stage.SetBackgroundColor( Vector4( 0.04f, 0.345f, 0.392f, 1.0f ) );
 
     TextField field = TextField::New();
@@ -68,6 +69,20 @@ public:
     stage.Add( field );
   }
 
+  /**
+   * Main key event handler
+   */
+  void OnKeyEvent(const KeyEvent& event)
+  {
+    if(event.state == KeyEvent::Down)
+    {
+      if( IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK ) )
+      {
+        mApplication.Quit();
+      }
+    }
+  }
+
 private:
 
   Application& mApplication;