From: Heonjae.Jang Date: Tue, 26 Sep 2017 09:02:05 +0000 (+0900) Subject: Removes Key Grab, Ungrab X-Git-Tag: submit/tizen_4.0/20170926.094442~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cfaf319725a3ac340ff9c708be2e0a845b36ad93;p=profile%2Ftv%2Fapps%2Fdotnet%2Fhome.git Removes Key Grab, Ungrab Change-Id: Ife171925e89dc6e10352cdc85683cad946fe57b2 Signed-off-by: Heonjae.Jang --- diff --git a/TVApps/TVApps.Tizen.TV/TVApps.TizenTV.cs b/TVApps/TVApps.Tizen.TV/TVApps.TizenTV.cs index 067aef0..0c73c7b 100644 --- a/TVApps/TVApps.Tizen.TV/TVApps.TizenTV.cs +++ b/TVApps/TVApps.Tizen.TV/TVApps.TizenTV.cs @@ -26,6 +26,7 @@ namespace TVApps.TizenTV /// public class Program : Xamarin.Forms.Platform.Tizen.FormsApplication, IAppLifeControl { + private static ElmSharp.EcoreEvent KeyUpEvent; /// /// The application instance /// @@ -57,25 +58,32 @@ namespace TVApps.TizenTV DbgPort.D("-----------------------------------"); LoadApplication(app); + + + KeyUpEvent = new ElmSharp.EcoreEvent(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; } + /// /// A method will be called when application receives KeyUp event /// /// The source of the event /// A EvasKey event's argument - 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(); } diff --git a/TVHome/TVHome.Tizen.TV/TVHome.TizenTV.cs b/TVHome/TVHome.Tizen.TV/TVHome.TizenTV.cs index 4cb7007..2b1184a 100755 --- a/TVHome/TVHome.Tizen.TV/TVHome.TizenTV.cs +++ b/TVHome/TVHome.Tizen.TV/TVHome.TizenTV.cs @@ -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 /// class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication { + private static ElmSharp.EcoreEvent KeyUpEvent; /// /// An interface for the platform notification /// @@ -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.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); } - /// - /// A method will be called when application receives KeyUp event - /// - /// The source of the event - /// A EvasKey event's argument - 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); } ///