Author Topic: Virtual Keyboard revisited.  (Read 576 times)


  • Full Member
  • ***
  • Posts: 229
Virtual Keyboard revisited.
« on: April 16, 2019, 07:57:25 am »
Environment: Linux Mint 19, Laz 2.0.0, FPC 3.0.4.


A brief summary of an intermittent effort to implement a virtual keyboard in Linux.

Around a year ago I ran into difficulties (my forum entry 'Virtual keyboard, dissapearing input' (March 2018)) but fortunately the requirement for a virtual keyboard went away as the project was stopped.

A few weeks ago I was asked to revisit the virtual keyboard and have done some research end experimentation. I note the following:

1. The example in Lazarus/components/mouseandkeyinput/examples is not good. The code for key input
demonstrates an Edit1.SetFocus for each 'KeyInput'. You get a single character in the Edit1 for each SetFocus pair.

2. The example by 'KpjComp' in 'Creating Virtual Keyboard' in the forum (November 2012) is good and works well.

So I based my efforts on the KpjComp code. I needed to invoke the virtual key board from a number of forms and used a Frame to contain the virtual keyboard and then included the Frame in multiple forms.

Complies clean but the code does not work! For example:

    tFKey : Class(TFrame)
    OneKey : tSpeedButton;

    procedure TFKey.SimpleKeyClick(Sender: TObject);
      // Passes the first character of the speedbutton.Caption to PressVirtkey.

    procedure TFKey.PressVirtKey(p: Int64);

    tFrmAdd : Class(TForm)
       Edit1 : tEdit;
       FKey : TFrame;

Give the Edit1 the focus. Click on 'OneKey' the PressVirtKey is executed, the Edit1 loses focus but no character is found in Edit1.Text.......

Tried all sorts of things and tests.
Moved the Edit1 to the Frame. Same problem.

Discarded the frame. Placed the Edit1 and OneKey one one form and everything worked!!!!

So what does a 'Frame' do to the flow of things in the program GUI and/or Linux????

Do I have to have multiple virtual keyboards? One per form or something like a 'keyboard' form (modal) with input objects (tEdit, etc) which passes information back to the calling code.

Any suggestions, brilliant ideas/insights, vast experience about implementing virtual keyboards.....???

Thanks, Ian.


TinyPortal © 2005-2018