| 3157 | |
| 3158 | /// {@inheritDoc} |
| 3159 | @Override |
| 3160 | public void keyPressed(int keyCode) { |
| 3161 | int game = Display.getInstance().getGameAction(keyCode); |
| 3162 | if (menuBar.handlesKeycode(keyCode)) { |
| 3163 | menuBar.keyPressed(keyCode); |
| 3164 | return; |
| 3165 | } |
| 3166 | |
| 3167 | //Component focused = focusManager.getFocused(); |
| 3168 | if (focused != null) { |
| 3169 | if (focused.isEnabled()) { |
| 3170 | focused.keyPressed(keyCode); |
| 3171 | } |
| 3172 | if (focused.handlesInput()) { |
| 3173 | return; |
| 3174 | } |
| 3175 | if (focused.getComponentForm() == this) { //NOPMD CompareObjectsWithEquals |
| 3176 | //if the arrow keys have been pressed update the focus. |
| 3177 | updateFocus(game); |
| 3178 | } else { |
| 3179 | initFocused(); |
| 3180 | } |
| 3181 | } else { |
| 3182 | initFocused(); |
| 3183 | if (focused == null) { |
| 3184 | getContentPane().moveScrollTowards(game, null); |
| 3185 | } |
| 3186 | } |
| 3187 | |
| 3188 | } |
| 3189 | |
| 3190 | /// Returns the layout manager of the form's content pane. |
| 3191 | /// |