(char c)
| 443 | |
| 444 | /// <inheritdoc /> |
| 445 | public override bool OnCharInput(char c) |
| 446 | { |
| 447 | if (base.OnCharInput(c)) |
| 448 | return true; |
| 449 | |
| 450 | // Find the item that starts with that character |
| 451 | if (char.IsLetterOrDigit(c) && _panel.VScrollBar != null && _panel.VScrollBar.Visible) |
| 452 | { |
| 453 | int startIndex = 0; |
| 454 | for (int i = 0; i < _panel.Children.Count; i++) |
| 455 | { |
| 456 | if (_panel.Children[i] is ContextMenuButton item && item.Visible && item.IsFocused) |
| 457 | { |
| 458 | // Start searching from the last hit item |
| 459 | startIndex = i + 1; |
| 460 | break; |
| 461 | } |
| 462 | } |
| 463 | for (int i = startIndex; i < _panel.Children.Count; i++) |
| 464 | { |
| 465 | if (_panel.Children[i] is ContextMenuButton item && item.Visible) |
| 466 | { |
| 467 | bool startsWith = false; |
| 468 | for (int j = 0; j < item.Text.Length; j++) |
| 469 | { |
| 470 | var k = item.Text[j]; |
| 471 | if (char.ToLower(k) == char.ToLower(c)) |
| 472 | { |
| 473 | startsWith = true; |
| 474 | break; |
| 475 | } |
| 476 | if (!char.IsWhiteSpace(k) && k != '>') |
| 477 | break; |
| 478 | } |
| 479 | if (startsWith) |
| 480 | { |
| 481 | // Focus found item |
| 482 | item.Focus(); |
| 483 | _panel.ScrollViewTo(item); |
| 484 | return true; |
| 485 | } |
| 486 | } |
| 487 | } |
| 488 | if (startIndex > 0 && startIndex <= _panel.Children.Count) |
| 489 | { |
| 490 | // No more items found so start from the top if there are matching items |
| 491 | _panel.Children[startIndex - 1].Defocus(); |
| 492 | return OnCharInput(c); |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | return false; |
| 497 | } |
| 498 | |
| 499 | /// <inheritdoc /> |
| 500 | public override bool OnKeyDown(KeyboardKeys key) |
nothing calls this directly
no test coverage detected