Recent

Author Topic: [SOLVED] virtual keyboard between forms  (Read 3794 times)

m.dj

  • New member
  • *
  • Posts: 7
[SOLVED] virtual keyboard between forms
« on: August 03, 2013, 03:25:46 pm »
Hi ,

I'm trying to add virtual keyboard to my application
so i used MouseAndKeyInput ,
the problem is i couldn't get it to work between the forms ( if the editable controls not in same form as the keyboard)

Simple project attached
Thanks
« Last Edit: August 05, 2013, 11:06:40 am by m.dj »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: virtual keyboard between forms
« Reply #1 on: August 03, 2013, 03:59:59 pm »
Code: [Select]
procedure TFormKeyboard.FormKeyPress(Sender: TObject; var Key: char);
begin
  case Key of
  'A': begin
         Form1.Memo1.SetFocus;
         Form1.Memo1.SelText := 'A';
         FormKeyboard.BringToFront;
       end;
end; 

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: virtual keyboard between forms
« Reply #2 on: August 03, 2013, 04:39:42 pm »
here is a quick take on the subject. Keep in mind that the modifications are windows only. I have no idea how to do the same on other systems.

There is the possibility that you can do the same thing if you save the handle given on the wmsetFocus method and make it active inside the simplekeyClick, SpecialKeyClick or the PressVirtKey method. I would try the simple/special keyclick first which allows the application to handle its messages before the keys are send.
« Last Edit: August 03, 2013, 04:46:20 pm by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

m.dj

  • New member
  • *
  • Posts: 7
Re: virtual keyboard between forms
« Reply #3 on: August 04, 2013, 11:06:04 am »
Hi ,
Thanks for the replays   :)
Quote
Keep in mind that the modifications are windows only
that's what i want (for now) , and it is working ;you saved me a lot of time thanks

Can i get the focused control before FormKeyboard showed ? thanks ;
« Last Edit: August 05, 2013, 11:07:13 am by m.dj »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: [SOLVED] virtual keyboard between forms
« Reply #4 on: August 05, 2013, 03:18:22 pm »
Why? I see no point in knowing that but you already have code that is executed when a control is clicked (for example) you have there the sender which should be the control that was clicked and if that is not enough (if you are using an action for example) you can use the Screen.FocusedForm.ActiveControl to get which control was last active.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

m.dj

  • New member
  • *
  • Posts: 7
Re: [SOLVED] virtual keyboard between forms
« Reply #5 on: August 05, 2013, 04:48:50 pm »
I'm trying to rebuild the virtual keyboard without using MouseAndKeyInput  %)
Thanks

 

TinyPortal © 2005-2018