resend key event in Linux

Vadim Zeitlin vadim at wxwindows.org
Thu May 3 07:56:06 PDT 2007


On Thu, 03 May 2007 16:22:44 +0200 Milan Babuskov <milanb at panonnet.net> wrote:

MB> Vadim Zeitlin wrote:
MB> > AM> > Andreas Micheler wrote:
MB> > AM> >> I'd like to use the wx event system rather than SendMessage,
MB> > AM> >> but it doesn't seem to work.
MB> > AM> >> What's the Linux equivalent to SendMessage?
MB> > AM> > 
MB> > AM> > It doesn't exist. You cannot just send a newly constructed
MB> > AM> > key event back to the control under Linux (GTK+),
MB> > 
MB> >  You can use EmulateKeyPress() method of wxTextCtrl. For the other controls
MB> > there is no way to do what you want.
MB> 
MB> At least, not with wxWidgets. However, you could use Xlib and make it 
MB> send a key to the focused window. It would go something like this:
MB> 
MB> Use XOpenDisplay to get connection to display,

 You can use wxGetX11Display() instead.

MB> then use XGetInputFocus to find the focused window (which is probably
MB> some Gtk control), and setup XKeyEvent structure and send it with
MB> XSendEvent.

 Yes, and you could, in principle, do the same with Win32 (SendMessage).
But wx doesn't wrap this functionality currently and, anyhow, even if it
did, it wouldn't work by sending wxEvents. However it could, indeed, be
useful to have it, at least for key (and maybe mouse) events.

 Regards,
VZ

-- 
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/





More information about the wx-users mailing list