Jump to content
Fabian1648

[Android BlueTooth] How to detect a ghost CR?

Recommended Posts

Hi,

 

Imagine an Android app developed with Delphi Rio that is connected to an external BlueTooth device (tests performed with barcode reader and keyboard).

 

When a Carriage Return (CR) is sent, the app triggers a "FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char;
Shift: TShiftState);" event. So the CR is detected!

 

If I use an Android text editor, the CR is taken into account.

 

But it's impossible to identify the CR character in the Delphi "FormKeyDown" event: an "Ord(KeyChar)" which should give a #13 (and which gives #13 if you compile for windows) gives 0, a "LEncoding.GetBytes(KeyChar)" also gives 0;

 

Same for the keyboard keys Backspace, Enter, Ctrl, Alt, Shift, Caps, F1...F12, Insert, Home, PgUp, Delete, End, PgDn, ..... which all give '0'!

 

A question arises... How to identify the arrival of a CR or other non-alphanumeric character?

 

Share this post


Link to post

Hello,

 

You should override form's KeyDown virtual method:

 

type
  TForm1 = class(TForm)
    procedure KeyDown(var Key: Word; var KeyChar: System.WideChar; Shift: TShiftState); override;
...

Search local help for FMX.Forms.TCommonCustomForm.KeyDown.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×