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

byungho jeon bastad at softfac.co.kr
Mon Mar 25 14:17:22 CET 2013


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130325/1d94dee6/attachment-0002.html>


More information about the Lazarus mailing list