Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-10

How send key events to a control with XSendEvent (without libXtst)

6 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

Hi!

I'm studding a way to create applications for touch screens. Sometimes I need enter data, but I don't have keyboard installed, so I searched a way to send key events to the control and I found the lazarus example mouseandkeyborardinput but it don't work very well (In the example it keeps the last char pressed and I don't know if it's application bug or libXtst) and it's linked with a library that isn't installed on Linux systems by default (on ubuntu I installed the libxtst-dev to get it working).

As an alternate way, I found the XSendEvent and XKeyEvent. My Question is: How fill the following record items to get it working at least with Gtk2/Qt?

I wrote this piece (that don't works :) )

procedure TForm1.Button1Click(Sender: TObject);
var
  vx:TXKeyEvent;
begin
  vx.display:=XOpenDisplay(nil);
  vx.window:= QWord(GTK_WINDOW(Pointer(edit1.Handle)));
  vx.root  := RootWindow(vx.display,DefaultScreen(vx.display));

Somebody?

Regards,

Fabio

Reply by email

Unknown author
to Unknown author

Only to register how solve this (GTK2)

procedure TForm2.SpeedButton7Click(Sender: TObject);
var
  vx:TXEvent;
begin
  vx.xkey.display := GDK_WINDOW_XDISPLAY(PGtkWidget(Ftarget.Handle)^.window);
  vx.xkey.window := GDK_WINDOW_XWINDOW(PGtkWidget(Ftarget.Handle)^.window);
  vx.xkey.root := RootWindow(vx.xkey.display,0);
  vx.xkey.subwindow := 0;
  vx.xkey.time := 5;
  vx.xkey.x := 1;
  vx.xkey.y := 1;
  vx.xkey.x_root := 1;
  vx.xkey.y_root := 1;
  vx.xkey.same_screen := 1;
  vx.xkey._type := x.KeyPress;
  vx.xkey.keycode := XKeysymToKeycode(vx.xkey.display,Ord((Sender AS
TSpeedButton).Caption[1]));
  vx.xkey.state := 0;
  XSendEvent (vx.xkey.display,vx.xkey.window,true,x.KeyPressMask, at vx);
  vx.xkey._type:=x.KeyRelease;
  XSendEvent (vx.xkey.display, vx.xkey.window,true,x.KeyReleaseMask, @vx);
end;

2010/10/16 :

Show quoted text 34 lines
Hi! I'm studding a way to create applications for touch screens. Sometimes I need enter data, but I don't have keyboard installed, so I searched a way to send key events to the control and I found the lazarus example mouseandkeyborardinput but it don't work very well (In the example it keeps the last char pressed and I don't know if it's application bug or libXtst) and it's linked with a library that isn't installed on Linux systems by default (on ubuntu I installed the libxtst-dev to get it working). As an alternate way, I found the XSendEvent and XKeyEvent. My Question is: How fill the following record items to get it working at least with Gtk2/Qt? I wrote this piece (that don't works :) ) procedure TForm1.Button1Click(Sender: TObject); var ?vx:TXKeyEvent; begin ?vx.display:=XOpenDisplay(nil); ?vx.window:= QWord(GTK_WINDOW(Pointer(edit1.Handle))); ?vx.root ?:= RootWindow(vx.display,DefaultScreen(vx.display)); Somebody? Regards, Fabio

Reply by email

zeljko
to Unknown author: Hi! I'm studding a way to create applications for touch screens. Sometimes I need enter…
Show quoted text 28 lines
Hi! I'm studding a way to create applications for touch screens. Sometimes I need enter data, but I don't have keyboard installed, so I searched a way to send key events to the control and I found the lazarus example mouseandkeyborardinput but it don't work very well (In the example it keeps the last char pressed and I don't know if it's application bug or libXtst) and it's linked with a library that isn't installed on Linux systems by default (on ubuntu I installed the libxtst-dev to get it working). As an alternate way, I found the XSendEvent and XKeyEvent. My Question is: How fill the following record items to get it working at least with Gtk2/Qt? I wrote this piece (that don't works :) ) procedure TForm1.Button1Click(Sender: TObject); var vx:TXKeyEvent; begin vx.display:=XOpenDisplay(nil); vx.window:= QWord(GTK_WINDOW(Pointer(edit1.Handle))); vx.root := RootWindow(vx.display,DefaultScreen(vx.display)); Somebody?

I've already implemented virtual keyboard in some of our commercial apps , using qt and sending events about key pressed. So, I'm creating and sending pure Qt event. Gtk will not work with this, but I don't care.

zeljko

Reply by email

Unknown author
to zeljko

Yes, the only thing that need be done to get it working on QT is get the XDisplay and XWindow, but I don?t know very well Qt. When it?s done maybe it can be a lazarus example?

Regards,

Fabio

2010/10/17 zeljko :

Show quoted text 14 lines
On Saturday 16 October 2010 16:49, wrote: > Only to register how solve this (GTK2) Then it's easy to use it under Qt too. in lcl/interfaces/qt how to get XDisplay and XWindow. zeljko -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

zeljko
to Unknown author
Yes, the only thing that need be done to get it working on QT is get the XDisplay and XWindow, but I don?t know very well Qt. When it?s done maybe it can be a lazarus example?

1.As I said, if you want to use X calls, there's qtx11.inc in lcl/interfaces/qt where you can see howto get XDisplay and other things from QX11Info class and can use previous X example for gtk2 and qt. 2.If you want to work directly with qt , then it's easy just create and QKeyEvent and send to widget (TQtWidget(YourTWinControl.Handle).Widget) which expects input.

zeljko

Reply by email