/// <summary> /// Constructs a new RemoteControlKeyEventArgs object for a key type, key name, and platform key name. /// </summary> /// <param name="sender">The VisualElement that sends the event.</param> /// <param name="keyType">The type of a remote control key.</param> /// <param name="keyName">The name of a remote control key.</param> /// <param name="platformKeyName">The name of a platform key name.</param> public RemoteControlKeyEventArgs(VisualElement sender, RemoteControlKeyTypes keyType, RemoteControlKeyNames keyName, string platformKeyName) { Sender = sender; KeyType = keyType; KeyName = keyName; PlatformKeyName = platformKeyName; }
protected override void OnAttached() { try { EcoreKeyEvents.Instance.KeyDown += OnKeyDown; _targetKeyName = InputEvents.GetAccessKey(Element); } catch (Exception e) { Log.Error(UIControls.Tag, $"Failed to attach the effect : {e.Message}"); } }
internal static RemoteControlKeyEventArgs Create(VisualElement visualElement, RemoteControlKeyTypes keyType, string keyName, bool isHandled = false) { RemoteControlKeyNames key = RemoteControlKeyNames.Unknown; if (!Enum.TryParse(keyName, out key)) { if (!Enum.TryParse("NUM" + keyName, out key)) { if (keyName.StartsWith("XF86")) { string simpleKeyName = keyName.Replace("XF86", "").Replace("Audio", ""); Enum.TryParse(simpleKeyName, out key); } } } return(new RemoteControlKeyEventArgs(visualElement, keyType, key, keyName) { Handled = isHandled }); }
/// <summary> /// Sets the access key to the specified view. /// When the access key is pressed, the specified view will directly get the focus and also be clicked if it is the Button. /// </summary> /// <param name="view">The view to be set.</param> /// <param name="value">The remote control key name to be set to the view.</param> public static void SetAccessKey(BindableObject view, RemoteControlKeyNames value) { view.SetValue(AccessKeyProperty, value); }