X11 question: setting widget focus policy

Vaughn Treude plug-discuss@lists.plug.phoenix.az.us
Tue, 29 Oct 2002 06:14:03 -0500


Hello all:
	Are there any X gurus out there?  I'm new to X programming, having spent 
most of my GUI programming time in Visual Studio.  Anyway, I'm trying to 
implement a global hotkey in a plain old X program.  (I don't want to use Qt 
or Gtk because I want it to be as portable as possible; plus it's not a very 
complicated application so I'd like to avoid that crazy "meta object" stuff 
for the time being.)  I've set up a translation table for my top-level widget 
with the XtVaAppInitialize call.  Its syntax looks fine according to what 
I've seen in X programming articles on the web.  I'm successfully capturing 
the ButtonDown and ButtonUp events (mouse clicks) and am also trying to 
capture the KeyPress and KeyRelease events.  But for some reason those 
keyboard event handlers never get executed.  My guess is that the top-level 
widget isn't set up to accept keyboard focus, being it only has buttons and 
no text-entry widgets on it.  It should be possible to set its properties to 
accept a keystroke, right?  I know there are calls like this to set the 
"focus policy" of the basic QWidget class in Qt.  Is there a way to do this 
in plain old Xt calls?  I have looked at the Widget definition in the X11R6 
header files, but nothing in there seems to relate to keyboard focus.  For 
the moment, I'm stuck here.  Any ideas?  Thanks!

Vaughn Treude
Nakota Software, Inc.