Keyboard input and meta keys
- From: Erik Andersen <andersen inconnect com>
- To: gtk-list redhat com
- Subject: Keyboard input and meta keys
- Date: Thu, 29 Oct 1998 15:41:23 -0700 (MST)
I am having the following problem with keyboard input, and I hope
that someone out there with a bit more experience can help me.
I have a program I am working on (Gnomehack -- nethack for gnome) that
is being written using Gtk--. I have in it a function that buffers up
keyboard presses, and then handles them when it is appropriate to do so.
As part of my GnomeHackWindow class, in the constructor I have the lines:
connect_to_method(key_press_event, this, &BufferKeyPress);
This seems to properly connect up the keyboard input to the BufferKeyPress
method, but here is where the problem comes in.
When I want the user to enter something like a "Z", instead I get
two keypresses -- a <shift> and then the "Z". Lower case charactors
work just fine. To try and handle this, I have had to do evil things
like:
gint GnomeHackWindow::BufferKeyPress(GdkEventKey* event)
{
if ( bHaveKeys == true) {
// Don't buffer up anything for meta keys like "shift"
if (
(event->keyval <= 0x20) ||
( (event->keyval >= 65505 ) && (event->keyval <= 65514 ) ) ||
(event->keyval == 65300) || (event->keyval == 65407) ||
(event->keyval == 65509) ) return 0;
else {
g_message("I got a \"%c\"\n", event->keyval);
m_Keybuffer.StoreKey( event->keyval);
return 0;
}
...
As you can imagine, doing all this special case stuff is only partially
effective, and it is absolutle horible and fragile. Does anyone know
the right way that I should go about getting only real (non-meta) keys?
What am I doing wrong with the keyboard event handling? Gtk+ or Gtk--
solutions would be warmly welcomed.
-Erik
--
Erik B. Andersen Web: http://www.inconnect.com/~andersen/
email: andersee@debian.org
--This message was written using 73% post-consumer electrons--
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]