45{
46 try {
47 const auto key_pressed {k.getKeyCode()};
48 const auto selected_row {juce::ListBox::getSelectedRow()};
49 const auto num_rows {juce::TableListBox::getNumRows()};
50 if (num_rows == 0 || selected_row == -1) { return false; }
51 if (key_pressed == juce::KeyPress::deleteKey) {
52 if (const auto ptr {
54 ptr->RemoveRow(gsl::narrow_cast<size_t>(selected_row));
55 juce::ListBox::updateContent();
56 if (selected_row == num_rows - 1) {
57 juce::ListBox::selectRow(num_rows - 2);
58 }
59 return true;
60 }
61 return false;
62 }
63 if (key_pressed == juce::KeyPress::downKey) {
64 juce::ListBox::selectRow(std::min(selected_row + 1, num_rows - 1));
65 return true;
66 }
67 if (key_pressed == juce::KeyPress::upKey) {
68 juce::ListBox::selectRow(std::max(selected_row - 1, 0));
69 return true;
70 }
71 if (key_pressed == juce::KeyPress::pageUpKey) {
72 juce::ListBox::selectRow(std::max(selected_row - 20, 0));
73 return true;
74 }
75 if (key_pressed == juce::KeyPress::pageDownKey) {
76 juce::ListBox::selectRow(std::min(selected_row + 20, num_rows - 1));
77 return true;
78 }
79 if (key_pressed == juce::KeyPress::homeKey) {
80 juce::ListBox::selectRow(0);
81 return true;
82 }
83 if (key_pressed == juce::KeyPress::endKey) {
84 juce::ListBox::selectRow(num_rows - 1);
85 return true;
86 }
87 return false;
88 }
89 catch (const std::exception& e) {
91 throw;
92 }
93}
Definition CommandTableModel.h:26