Removes Key Grab, Ungrab 31/152531/1
authorHeonjae.Jang <Heonjae.Jang@samsung.com>
Tue, 26 Sep 2017 09:02:05 +0000 (18:02 +0900)
committerHeonjae.Jang <Heonjae.Jang@samsung.com>
Tue, 26 Sep 2017 09:02:05 +0000 (18:02 +0900)
Change-Id: Ife171925e89dc6e10352cdc85683cad946fe57b2
Signed-off-by: Heonjae.Jang <Heonjae.Jang@samsung.com>
TVApps/TVApps.Tizen.TV/TVApps.TizenTV.cs
TVHome/TVHome.Tizen.TV/TVHome.TizenTV.cs

index 067aef0..0c73c7b 100644 (file)
@@ -26,6 +26,7 @@ namespace TVApps.TizenTV
     /// </summary>
     public class Program : Xamarin.Forms.Platform.Tizen.FormsApplication, IAppLifeControl
     {
+        private static ElmSharp.EcoreEvent<ElmSharp.EcoreKeyEventArgs> KeyUpEvent;
         /// <summary>
         /// The application instance
         /// </summary>
@@ -57,25 +58,32 @@ namespace TVApps.TizenTV
             DbgPort.D("-----------------------------------");
             LoadApplication(app);
 
+
+
+            KeyUpEvent = new ElmSharp.EcoreEvent<ElmSharp.EcoreKeyEventArgs>(ElmSharp.EcoreEventType.KeyUp,
+                (s, e, t) =>
+                {
+                    return ElmSharp.EcoreKeyEventArgs.Create(s, e, t);
+                });
+
             PackageManagerPort.RegisterCallbacks(notification);
             MainWindow.Alpha = true;
-            MainWindow.KeyUp += KeyUpListener;
 
-            MainWindow.KeyGrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName, true);
-            MainWindow.KeyGrab("XF86Info", true);
+            KeyUpEvent.On += KeyUpListener;
         }
 
+
         /// <summary>
         /// A method will be called when application receives KeyUp event
         /// </summary>
 
         /// <param name="sender">The source of the event</param>
         /// <param name="args">A EvasKey event's argument</param>
-        private void KeyUpListener(object sender, ElmSharp.EvasKeyEventArgs args)
+        private void KeyUpListener(object sender, ElmSharp.EcoreKeyEventArgs e)
         {
-            DebuggingUtils.Dbg("[TVApps.TizenTV.cs] Key Pressed :" + args.KeyName);
-            if (args.KeyName.CompareTo(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName) == 0 ||
-                args.KeyName.CompareTo("XF86Info") == 0)
+            DebuggingUtils.Dbg("[TVApps.TizenTV.cs] Key Pressed :" + e.KeyName);
+            if (e.KeyName.CompareTo(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName) == 0 ||
+                e.KeyName.CompareTo("XF86Info") == 0)
             {
                 notification?.OnMenuKeyPressed();
             }
index 4cb7007..2b1184a 100755 (executable)
@@ -18,6 +18,8 @@ using Tizen.Applications;
 using LibTVRefCommonPortable.Utils;
 using LibTVRefCommonTizen.Ports;
 using Tizen.Xamarin.Forms.Extension.Renderer;
+using ElmSharp;
+using System;
 
 namespace TVHome.TizenTV
 {
@@ -26,6 +28,7 @@ namespace TVHome.TizenTV
     /// </summary>
     class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication
     {
+        private static ElmSharp.EcoreEvent<ElmSharp.EcoreKeyEventArgs> KeyUpEvent;
         /// <summary>
         /// An interface for the  platform notification
         /// </summary>
@@ -60,30 +63,23 @@ namespace TVHome.TizenTV
             LoadApplication(app);
 
             PackageManagerPort.RegisterCallbacks(notification);
-
-            MainWindow.KeyUp += KeyUpListener;
             MainWindow.Alpha = true;
 
             windowPort = new WindowPort();
             windowPort.MainWindow = MainWindow;
 
-            /// Grab key events
-            MainWindow.KeyGrab(ElmSharp.EvasKeyEventArgs.PlatformHomeButtonName, true);
-            MainWindow.KeyGrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName, true);
-            MainWindow.KeyGrab("XF86Info", true);
-            MainWindow.KeyGrab("Up", false);
-            MainWindow.KeyGrab("Down", false);
-            MainWindow.KeyGrab("Left", false);
-            MainWindow.KeyGrab("Right", false);
+            KeyUpEvent = new ElmSharp.EcoreEvent<ElmSharp.EcoreKeyEventArgs>(ElmSharp.EcoreEventType.KeyUp,
+                (s, e, t) =>
+                {
+                    return ElmSharp.EcoreKeyEventArgs.Create(s, e, t);
+                });
+
+            KeyUpEvent.On += KeyUpListener;
+            MainWindow.KeyGrab(EvasKeyEventArgs.PlatformHomeButtonName,true);
             windowPort.SetKeyGrabExclusively(ElmSharp.EvasKeyEventArgs.PlatformHomeButtonName);
         }
 
-        /// <summary>
-        /// A method will be called when application receives KeyUp event
-        /// </summary>
-        /// <param name="sender">The source of the event</param>
-        /// <param name="e">A EvasKey event's argument</param>
-        private void KeyUpListener(object sender, ElmSharp.EvasKeyEventArgs e)
+        private void KeyUpListener(object sender, EcoreKeyEventArgs e)
         {
             DbgPort.D("Key Pressed :" + e.KeyName);
             if (e.KeyName.CompareTo(ElmSharp.EvasKeyEventArgs.PlatformHomeButtonName) == 0)
@@ -110,13 +106,8 @@ namespace TVHome.TizenTV
 
             notification = null;
             PackageManagerPort.UnregisterCallbacks();
-            MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformHomeButtonName);
-            MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName);
-            MainWindow.KeyUngrab("XF86Info");
-            MainWindow.KeyUngrab("Up");
-            MainWindow.KeyUngrab("Down");
-            MainWindow.KeyUngrab("Left");
-            MainWindow.KeyUngrab("Right");
+            KeyUpEvent.On -= KeyUpListener;
+            MainWindow.KeyUngrab(EvasKeyEventArgs.PlatformHomeButtonName);
         }
 
         /// <summary>