| 74 | } |
| 75 | |
| 76 | bool ProgramListBox::keyPressed(const KeyPress &key, Component *originatingComponent) { |
| 77 | ProgramLabel *programLabel = dynamic_cast<ProgramLabel*>(getCurrentlyFocusedComponent()); |
| 78 | if ( programLabel == nullptr ) |
| 79 | return false; |
| 80 | |
| 81 | if ( key.isKeyCode(KeyPress::returnKey) ) { |
| 82 | activePgm = programLabel->idx; |
| 83 | if ( activePgm != -1 ) { |
| 84 | listener->programSelected(this, activePgm); |
| 85 | } |
| 86 | return true; |
| 87 | } |
| 88 | |
| 89 | int currentIdx = programLabel->idx; |
| 90 | |
| 91 | if ( key.isKeyCode(KeyPress::upKey) ) { |
| 92 | currentIdx--; |
| 93 | if ( currentIdx < 0 ) |
| 94 | currentIdx += rows; |
| 95 | } else if ( key.isKeyCode(KeyPress::downKey) ) { |
| 96 | currentIdx++; |
| 97 | if ( currentIdx >= 32 ) |
| 98 | currentIdx -= rows; |
| 99 | } else if ( key.isKeyCode(KeyPress::leftKey) ) { |
| 100 | currentIdx -= rows; |
| 101 | if ( currentIdx < 0 ) |
| 102 | currentIdx += 32; |
| 103 | } else if ( key.isKeyCode(KeyPress::rightKey) ) { |
| 104 | currentIdx += rows; |
| 105 | if ( currentIdx >= 32 ) |
| 106 | currentIdx -= 32; |
| 107 | } else { |
| 108 | return false; |
| 109 | } |
| 110 | |
| 111 | labels[currentIdx]->grabKeyboardFocus(); |
| 112 | |
| 113 | repaint(); |
| 114 | return true; |
| 115 | } |
| 116 | |
| 117 | void ProgramListBox::paint(Graphics &g) { |
| 118 | g.fillAll(DXLookNFeel::background); |
nothing calls this directly
no test coverage detected