public override bool ProcessKey(KeyEvent kb) { switch (kb.Key) { case Key.CursorUp: current--; if (current < 0) { current = barItems.Children.Length - 1; } SetNeedsDisplay(); break; case Key.CursorDown: current++; if (current == barItems.Children.Length) { current = 0; } SetNeedsDisplay(); break; case Key.CursorLeft: host.PreviousMenu(); break; case Key.CursorRight: host.NextMenu(); break; case Key.Esc: host.CloseMenu(); break; case Key.Enter: host.CloseMenu(); Run(barItems.Children [current].Action); break; default: // TODO: rune-ify if (Char.IsLetterOrDigit((char)kb.KeyValue)) { var x = Char.ToUpper((char)kb.KeyValue); foreach (var item in barItems.Children) { if (item.HotKey == x) { host.CloseMenu(); Run(item.Action); return(true); } } } break; } return(base.ProcessKey(kb)); }
public override bool ProcessKey(KeyEvent kb) { bool disabled; switch (kb.Key) { case Key.CursorUp: if (current == -1) { break; } do { disabled = false; current--; if (host.UseKeysUpDownAsKeysLeftRight) { if (current == -1 && barItems.Children [current + 1].IsFromSubMenu && host.selectedSub > -1) { current++; host.PreviousMenu(true); break; } } if (current < 0) { current = barItems.Children.Length - 1; } var item = barItems.Children [current]; if (item == null || !item.IsEnabled()) { disabled = true; } } while (barItems.Children [current] == null || disabled); SetNeedsDisplay(); break; case Key.CursorDown: do { current++; disabled = false; if (current == barItems.Children.Length) { current = 0; } var item = barItems.Children [current]; if (item == null || !item.IsEnabled()) { disabled = true; } if (host.UseKeysUpDownAsKeysLeftRight && barItems.Children [current]?.SubMenu != null && !disabled && !host.isMenuClosed) { CheckSubMenu(); break; } if (host.isMenuClosed) { host.OpenMenu(host.selected); } } while (barItems.Children [current] == null || disabled); SetNeedsDisplay(); break; case Key.CursorLeft: host.PreviousMenu(true); break; case Key.CursorRight: host.NextMenu(barItems.Children [current].IsFromSubMenu ? true : false); break; case Key.Esc: Application.UngrabMouse(); host.CloseAllMenus(); break; case Key.Enter: CheckSubMenu(); Run(barItems.Children [current].Action); break; default: // TODO: rune-ify if (Char.IsLetterOrDigit((char)kb.KeyValue)) { var x = Char.ToUpper((char)kb.KeyValue); foreach (var item in barItems.Children) { if (item == null) { continue; } if (item.IsEnabled() && item.HotKey == x) { host.CloseMenu(); Run(item.Action); return(true); } } } break; } return(true); }