Keyboard use

25 views
Skip to first unread message

Jeff Amiel

unread,
Feb 5, 2015, 12:49:27 AM2/5/15
to game-g...@googlegroups.com
For those that happen to come late to the party....

I couldn't seem to get ANY of the traditional listener or keybindings methods to work - they were simply ignored (or possibly 'eaten' by listeners elsewhere?)
After too many hours of beating my head against the wall, I ended up using the 'built in' KeyboardManager (https://www.threerings.net/code/nenya/docs/api/com/threerings/util/KeyboardManager)

I extended KeyboardManager (didn't override much) and had my VirtualMediaPanel (or just MediaPanel for some of you) implement the KeyObserver interface.

I instantiated the keyboard manager (in the VirtualMediaPanel constructor)  , set it's target to 'this' (the VirtualMediaPanel) and passed a dummy KeyTranslatorImpl - then enabled it:

 myKeyboardManager.setTarget(this, new KeyTranslatorImpl());
 myKeyboardManager.setEnabled(true);

I added a "handleKeyEvent" function to my panel and was off and running capturing keystrokes!!




Reply all
Reply to author
Forward
0 new messages