| 516 | } |
| 517 | |
| 518 | void PluginDataViewCtrl::OnCharEvent(wxKeyEvent& evt) |
| 519 | { |
| 520 | evt.Skip(); |
| 521 | #if defined(wxHAS_GENERIC_DATAVIEWCTRL) |
| 522 | // |
| 523 | if(evt.GetKeyCode() == WXK_CONTROL_A && |
| 524 | evt.GetModifiers() | WXK_COMMAND) |
| 525 | { |
| 526 | SelectAll(); |
| 527 | evt.Skip(false); |
| 528 | return; |
| 529 | } |
| 530 | if(evt.GetKeyCode() == WXK_SPACE || |
| 531 | evt.GetKeyCode() == WXK_RETURN || |
| 532 | evt.GetKeyCode() == WXK_NUMPAD_ENTER) |
| 533 | { |
| 534 | return; |
| 535 | } |
| 536 | |
| 537 | const auto ch = evt.GetUnicodeKey(); |
| 538 | if(ch == WXK_NONE) |
| 539 | return; |
| 540 | |
| 541 | auto item = GetCurrentItem(); |
| 542 | if(!item.IsOk()) |
| 543 | return; |
| 544 | |
| 545 | //if item.IsOk(), then there is at least 1 item in the table |
| 546 | const auto searchStartRow = GetRowByItem(item); |
| 547 | auto row = searchStartRow + 1; |
| 548 | while(true) |
| 549 | { |
| 550 | item = GetItemByRow(row); |
| 551 | |
| 552 | if(!item.IsOk()) |
| 553 | { |
| 554 | if(row > searchStartRow) |
| 555 | { |
| 556 | //start from the beginning, until we reach |
| 557 | //searchStartRow again |
| 558 | row = 0; |
| 559 | continue; |
| 560 | } |
| 561 | break; |
| 562 | } |
| 563 | |
| 564 | wxVariant data; |
| 565 | GetModel()->GetValue(data, item, PluginDataModel::ColumnName); |
| 566 | const auto name = data.GetString(); |
| 567 | if(!name.empty() && name.Left(1).IsSameAs(ch, false)) |
| 568 | { |
| 569 | wxDataViewItemArray sel; |
| 570 | sel.push_back(item); |
| 571 | SetSelections(sel); |
| 572 | SetCurrentItem(sel[0]); |
| 573 | EnsureVisible(sel[0]); |
| 574 | break; |
| 575 | } |