MCPcopy Create free account
hub / github.com/audacity/audacity / OnCharEvent

Method OnCharEvent

src/PluginDataViewCtrl.cpp:518–584  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

516}
517
518void 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 }

Callers

nothing calls this directly

Calls 7

SkipMethod · 0.80
IsOkMethod · 0.45
GetValueMethod · 0.45
GetStringMethod · 0.45
emptyMethod · 0.45
IsSameAsMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected