45{
46 try {
47 const auto key_pressed {k.getKeyCode()};
48 if (key_pressed == juce::KeyPress::deleteKey) {
49 if (juce::ListBox::getSelectedRow() != -1) {
50 const auto last {
51 juce::ListBox::getSelectedRow() == juce::TableListBox::getNumRows() - 1};
52 if (const auto ptr {
54 ptr->RemoveRow(gsl::narrow_cast<size_t>(juce::ListBox::getSelectedRow()));
55 }
56 juce::ListBox::updateContent();
57 if (last) {
58 juce::ListBox::selectRow(getNumRows() - 1);
59 }
60 return true;
61 }
62 return false;
63 }
64 if (key_pressed == juce::KeyPress::downKey) {
65 if (juce::ListBox::getSelectedRow() != -1
66 && juce::ListBox::getSelectedRow() < juce::TableListBox::getNumRows() - 1) {
67 juce::ListBox::selectRow(getSelectedRow() + 1);
68 return true;
69 }
70 return false;
71 }
72 if (key_pressed == juce::KeyPress::upKey) {
73 if (juce::ListBox::getSelectedRow() > 0 && juce::TableListBox::getNumRows() > 1) {
74 juce::ListBox::selectRow(getSelectedRow() - 1);
75 return true;
76 }
77 return false;
78 }
79 if (key_pressed == juce::KeyPress::pageUpKey) {
80 if (juce::TableListBox::getNumRows() > 0) {
81 juce::ListBox::selectRow(std::max(juce::ListBox::getSelectedRow() - 20, 0));
82 return true;
83 }
84 return false;
85 }
86 if (key_pressed == juce::KeyPress::pageDownKey) {
87 if (juce::TableListBox::getNumRows() > 0) {
88 juce::ListBox::selectRow(std::min(juce::ListBox::getSelectedRow() + 20,
89 juce::TableListBox::getNumRows() - 1));
90 return true;
91 }
92 return false;
93 }
94 if (key_pressed == juce::KeyPress::homeKey) {
95 if (juce::TableListBox::getNumRows() > 0) {
96 juce::ListBox::selectRow(0);
97 return true;
98 }
99 return false;
100 }
101 if (key_pressed == juce::KeyPress::endKey) {
102 if (juce::TableListBox::getNumRows() > 0) {
103 juce::ListBox::selectRow(juce::TableListBox::getNumRows() - 1);
104 return true;
105 }
106 return false;
107 }
108 return false;
109 }
110 catch (const std::exception& e) {
112 throw;
113 }
114}
Definition CommandTableModel.h:26