GameControl Feature Request

Your frogness!



I looked for a way to catch all mouse and key events that have no bindings assigned, but I found nothing like this (maybe I overlooked something).



This feature could be handy e.g. for leaving status screens, assigning key-mappings or just to give the user a response like "I got your click, but it was something stupid".



Would it be possible to have something like:



GameControl control = new manager.addControl("control");
control.addBinding(new DefaultKeyBinding());
control.addBinding(new DefaultMouseBinding());

I'm not sure exactly what you're asking…take a look at TestSwingControlEditor and see if that doesn't have the functionality you're looking for?

I'm asking for a possibility to get all key and mouseevents that have no bindings assigned.



E.g. when you show the player a status screen like "Congratulations, you eliminated all bandersnatches! Press any key to continue", how would you implement the infamous "any key"?

This would probably not want to be implemented in GameControls, but rather add a listener.



Take a look at ControlFieldListener and see if that is more what you're wanting.

Thanks, I'll have a look at it.



The reason I thought GameControls would be a good place is, that I don't want to consume events that have already a binding.

Why not?  I thought you were talking about detecting if "any key" was pressed?


He said he wants to "catch all mouse and key events that have no bindings assigned". He said it the other way (any key) to help you understand what he wanted. Said another way, he wants to have anything with a binding to do the thing it's supposed to do, and anything that does not have a binding, he wants to handle specially.

I think :)

Cheers,
Stan

Ah, the ol' infamous "Any key; BUT NOT THAT ONE!"  :stuck_out_tongue:

I don't have the code in front of me, but in that same package there is code to determine conflicts with keybindings, so you could use that in order to do what you're wanting.

Thank you, I'll try it.



Ah, the ol' infamous "Any key; BUT NOT THAT ONE!" 


EXACTLY!  XD

However, I should think that a screen that says "Press any key" even if it appears above your character in the game and you press "walk forward" it should cause the action to be invoked on that screen even if you still wanted to walk forward.



Things brings up an idea for a new feature to GameControl:


public boolean isAnyKey() {
    return true;
}



I'll get that checked in if you find it useful. ;)

[move]Thank you very much! Such an easy and elegant solution! Please check it in! Immediately! [/move] :smiley:

Note to all devs - please immediately ban the marquee tag from being used in posts!  :wink: