InputHandler BufferedKeyActions

… appear to have been broken recently ?



What I am doing is adding my own KeyInputAction as a buffered key action to a InputHandler, in order to get all key events as they happen.



So I’m doing something like this:


KeyInputAction f = new KeyInputAction() {
   public void performAction(InputActionEvent evt)
        {
       System.out.println( "action performed " + evt);      
        }
};

inputHandler.addBufferedKeyAction( f );



However, this action never gets called.

Digging into the InputHandler update() code, it seems to me that the following code (starting at line 280):

if (useBufferedKeyboard && keyboard != null) {
...
 ((InputAction) buffKeyActions.get(i)).setKey(kInput.getKeyName(kInput.key()));
((KeyInputAction) buffKeyActions.get(i)).setKeyChar(kInput.keyChar());

eventList.add(((InputAction) keyActions.get(i)).getKey());
actionList.add(keyActions.get(i));
...




should actually be:

if (useBufferedKeyboard && keyboard != null) {
...
 ((InputAction) buffKeyActions.get(i)).setKey(kInput.getKeyName(kInput.key()));
((KeyInputAction) buffKeyActions.get(i)).setKeyChar(kInput.keyChar());

eventList.add(((InputAction) buffKeyActions.get(i)).getKey());
actionList.add(buffKeyActions.get(i));
...



with those last two lines adding objects from the buffKeyActions List, not the keyActions List.

making this change gets things working again for me.

there also appears to be new wierdness regarding InputHandlers with only a single keyboardAction set, but more on that when i get a moment...

ok, seems I didn’t test all the cases I should have tested when adding the event stuff. Just list the bugs here and I’ll fix them.



Your fix has been committed.