/// </summary>
public class Program : Xamarin.Forms.Platform.Tizen.FormsApplication, IAppLifeControl
{
+ private static ElmSharp.EcoreEvent<ElmSharp.EcoreKeyEventArgs> KeyUpEvent;
/// <summary>
/// The application instance
/// </summary>
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();
}
using LibTVRefCommonPortable.Utils;
using LibTVRefCommonTizen.Ports;
using Tizen.Xamarin.Forms.Extension.Renderer;
+using ElmSharp;
+using System;
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>
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)
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>