[Lazarus] TForm.OnKeyPress event missing some characters using usb barcode reader

Bernd prof7bit at gmail.com
Mon May 23 12:45:16 CEST 2016


I can confirm this behavior with Lazarus 1.6 (gtk2) / FPC 3.0 on Xubuntu 16.04.

Typing keys rapidly (even by hand with a normal keyboard) will make it
lose keypress events occasionally, using a barcode reader (it emulates
an USB-Keyboard) through the KeyPress event is virtually impossible
with Gtk2-LCL. No problems on Windows.

Bypassing the LCL and binding a handler directly to the gtk signal
proves that gtk will fire events for *all* keys, no matter how rapidly
the keyboard will send them, its just LCL that is missing some of them
:-(

2013-03-25 14:17 GMT+01:00 byungho jeon <bastad at softfac.co.kr>:
> I'm using CodeTyphon 4.10 on ubuntu mint 14 desktop (x86-64)
> - CodeTyphon 4.10 = FPC 2.7.1, Lazarus 2013-03-25 SVN 40461CT
> x86_64-linux-gtk2
>
> Barcode reader is MOTOROLA DS3578 with FIPS model (configed HID Keyboard
> Emulation, USB Type)
>
> I make reader code using TForm.KeyPreview property.
>
> 1. There is main form. (Keypreview := True)
> 2. Make OnKeyPress event handler
> 3. Read a sample QRCode ( http://localhost/qrcode/Test_2012/A001 )
> 4. OnKeyPress missing some characters.
>     -> Readed -> http://localhost/qrcode/est2012/001
>     -> Missed capital character(T, A) and under bar character(_)
>     -> Lower case character is no problem.
>
> When I read barcode(qrcode) focus to text editor like pluma, qrcode data is
> inserted correctly without missing characters.
>
> Here is test project main form unit source code:
>
> //----------------------------------- SAMPLE CODE
> unit Unit1;
>
> {$mode objfpc}{$H+}
>
> interface
>
> uses
>   Classes, SysUtils, FileUtil, ubarcodes, Forms, Controls, Graphics,
> Dialogs,
>   StdCtrls, LCLType;
>
> type
>   { TForm1 }
>   TForm1 = class(TForm)
>     Button1: TButton;
>     Button2: TButton;
>     procedure Button1Click(Sender: TObject);
>     procedure Button2Click(Sender: TObject);
>     procedure FormCreate(Sender: TObject);
>     procedure FormKeyPress(Sender: TObject; var Key: char);
>   private
>     FBuffer: string;
>   public
>     { public declarations }
>   end;
>
> var
>   Form1: TForm1;
>
> implementation
>
> {$R *.lfm}
>
> { TForm1 }
>
> procedure TForm1.FormCreate(Sender: TObject);
> begin
>   KeyPreview := True;
> end;
>
> procedure TForm1.FormKeyPress(Sender: TObject; var Key: char);
> begin
>   FBuffer += Key;
> end;
>
> procedure TForm1.Button1Click(Sender: TObject);
> begin
>   ShowMessage(FBuffer);
> end;
>
> procedure TForm1.Button2Click(Sender: TObject);
> begin
>   FBuffer := '';
> end;
>
> end.
>
>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>




More information about the Lazarus mailing list