Monday, March 05, 2007

Java + keyboard bindings

= Insanity.

I want to connect all input keys to a single widget. And I don't want to have to use 16 classes in the process. And I want all the Java library developers to get their come-uppance.

*sigh*

4 comments:

Anonymous said...

Well, why don't you just create a single class, which implements all the Listener Interfaces?

Robert Ancell said...

The problem is keyboard focus. I really want all the keyboard events coming into my application (it contains a terminal emulator as a main part).

The problem was the code I'm refactoring extended java.awt.FocusTraversalPolicy and caught key events from the central key manager. Programmers tend to think they're more clever than they are and provided with highly complex interfaces (i.e. Java) they come up with complex and unstable solutions. In languages where these things are simple (either focus works simply and well or it is easy to redirect events to one widget) people don't do this. I also hate C++ for similar reasons...

The solution involved me stopping wasting time trying to understand what they were doing, ripping out all this code and ensuring the terminal window always has focus. And now it works without a ton of code.

And listener interfaces are yuck for common signals. What if you have n widgets which you want to get events from? You either need n classes to avoid the method name collision or a big switch/if-else statement in the one handler.

Hamish Twaddle said...

I think chesse tastes much better

Hamish Twaddle said...

I see glchess is now default in Ubuntu Fawn 7.04

HAT