mån 2012-03-19 klockan 13:37 -0800 skrev Christopher Howard: > So, you mean, receive both key press and key release events, and then > maintain my own tracking of whether or not the key is currently being > held down? Okay, that makes sense to me, provided of course I can be > certain that all key press and key release events are properly reported > to my program (otherwise my internal state my gets screwed) and in the > correct order. > > However, the approach I was hoping for, i.e. simply checking the current > "reality" state of a key (whether it is actually pressed down or not) > sounds more convenient. If anyone could tell me how to do that, I would > be grateful.
Which you can't, key events (all events ?) in X11 is edge triggered. > BTW, in the ClanLib program I did something like so: > > code: > ---------- > // initialize keyboard object > CL_InputDevice keyboard = window.get_ic().get_keyboard(); > > // ...snip... > > // start main loop > > /* get_keycode() would check if that key was currently depressed > Obviously, not a very practical approach for word processing > or typing into a text box, but simple and quite appropriate > in, say, a space combat game > */ > if(keyboard.get_keycode(49)) // do something You should understand that the way to deal with events in Gdk is decided by how X11 deals with for example key events. You should pick up the key_down event and key_release event but you should also pick up the enter_focus and leave_focus events (window looses keyboard focus = window won't get any key events.) The program should get a consistent view of keyboard key state if the program as such is prepared to deal with the focus events. _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list