Re: GTK+2.2 and Key Bindings



On Wed, Jun 11, 2003 at 08:16:21PM +0000, Keith Maika wrote:
I'm making a small app that floats on the desktop with an input box, and 
I'd like to make it possible that when you press CTRL+F12, no matter 
where you are at, it will give this window focus, highlight everything, 
and let you type.  What I can't figure out is if it's possible to make 
that kind of a keyboard shortcut using GTK+ or if I'd have to tie into 
the X windows system directly to capture the keypress or if I'd have to 
tie into the WM (in which case I may drop the idea unless there's a 
standard way to do this).

I guess what I'm looking for is the gtk equivlent of the Win32API call 
RegisterHotkey()


You have to use Xlib, the API call is called XGrabKey().  For GNOME
we've been trying to move all usage of this API into the window
manager, so that collisions can be handled more gracefully, etc.  But
it's generally fine to use it directly (if someone else has already
grabbed your key, then the XGrabKey() will simply fail - you may need
to gdk_error_trap_push() around the XGrabKey() to handle that).

Havoc




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]