[sdljava-users] guichan sdlinput - most key not handled
Status: Beta
Brought to you by:
ivan_ganza
|
From: David L. <sys...@ho...> - 2005-07-25 19:30:11
|
Hi,
I've tried to use a guichan TextField but found that most of the key input
aren't handled. The special cases like the arrows or the delete key work
fine, but the common letters and numbers aren't recognized as input. The Key
event generated by the keypressed has a keyvalue of 0.
I believe the problem is in the sdljavax.guichan.sdl.SDLInput
convertKeyCharacter method. The first block seems to handle those numbers
and letters but really doesn't.
private Key convertKeyCharacter(SDLKeyboardEvent keysym) {
int value = 0;
if (keysym.getUnicode() < 255) {
value = keysym.getUnicode();
}
switch (keysym.getSym()) {
case SDLKey.SDLK_TAB :
value = Key.TAB;
break;
...
}
...
}
I've added the following in the switch statement, and it fixes the problem:
case SDLKey.SDLK_a:
value = (int)'a';
break;
... for each letter and number
I'm not sure if that's the best solution. Perhaps someone might know why the
getUnicode() method returns 0. I'm using Windows XP by the way, I don't know
if it matters.
Anyhow, yay my first somewhat-contribution to an open source project!
Cheers,
David Lareau
|