Browse Source

Handle Enter key in menus.

pull/58/head
Steven Kirk 11 years ago
parent
commit
4ff5afad9e
  1. 25
      Perspex.Controls/MenuItem.cs

25
Perspex.Controls/MenuItem.cs

@ -173,18 +173,7 @@ namespace Perspex.Controls
/// </summary>
public bool IsTopLevel
{
get;
private set;
}
/// <summary>
/// Called when the <see cref="MenuItem"/> is attached to the visual tree.
/// </summary>
/// <param name="root">The root of the visual tree.</param>
protected override void OnAttachedToVisualTree(IRenderRoot root)
{
base.OnAttachedToVisualTree(root);
this.IsTopLevel = this.Parent is Menu;
get { return this.Parent is Menu; }
}
/// <summary>
@ -259,6 +248,18 @@ namespace Perspex.Controls
passStraightToParent = this.IsTopLevel || !this.IsSubMenuOpen;
break;
case Key.Enter:
if (this.HasSubMenu)
{
goto case Key.Right;
}
else
{
this.RaiseEvent(new RoutedEventArgs(ClickEvent));
}
break;
case Key.Escape:
if (this.IsSubMenuOpen)
{

Loading…
Cancel
Save