Recent

Author Topic: Touch screen keyboard  (Read 14213 times)

coyote973

  • Newbie
  • Posts: 2
Touch screen keyboard
« on: August 04, 2011, 02:45:01 pm »
Hi,

I would like to make a program for touch panel, but I cant find any component for Lazarus. When I click on EditBox the keyboard should pop-up (different types of it, for numeric field, text field), edit/change value  and when enter is pressed writeback in edit box value.
I have tried to make myself a unit, but I am just a beginner, this should work without windows API calls.
I would apreciate any help, thank you.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Touch screen keyboard
« Reply #1 on: August 05, 2011, 10:47:49 am »
You should really read some tutorials first. Search forum for Lazarus books and tutorials. Take a look at what wiki offers on this topic. If you want to get help then you need to do your homework first. Quick hint: walk through this calculator 'hello world' application at http://wiki.lazarus.freepascal.org/Howdy_World_%28Hello_World_on_steroids%29 and actually make it your self with provided step by step instructions. Then take a look at OnMouseUp event of TEdit in documentation here: http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tedit.html. Then try to show some dummy form when you release button of the mouse over your Edit input field. Then put buttons 'Q', 'W', 'E', 'R', 'T', 'Y' or whatever letters you need on that dummy form and also put single Edit there and hard code OnClick event of each button to add labeled character from a button to Edit (advanced use would be to make all buttons call the same OnClick event where you copy character shown on the button itself, but never mind if you can't make it that way). Then implement backspace and other special buttons you need, and make two buttons like 'Finish' and 'Cancel'. Both will close the dummy form, but first will also copy Edit string from dummy form to your main form. In order to make this universal, you will have to provide caller info to the dummy form, so any Edit on any form in your application can call your dummy form. You can expand this idea further, but even doing just this makes dummy form a virtual keyboard you want. No Windows API calls at all.

I am not aware of Lazarus virtual keyboard component, and the closest found is a Delphi one where you can study the source (although that's definitely not for a newbie):
http://www.delphipages.com/comp/virtual_keyboard-3342.html

You could also take a look at accessibility On-Screen Keyboard shipped with every Windows.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

coyote973

  • Newbie
  • Posts: 2
Re: Touch screen keyboard
« Reply #2 on: August 05, 2011, 02:28:38 pm »
Thank you very much for the example, I will study the code, I have soon noticed that it uses Windows, perhaps there are some extra function that could be deleted for non-windows user.

I have also found a similar post:

http://www.lazarus.freepascal.org/index.php?topic=12595.0

And I totaly agree with you, that's what my wishes are, on click event on EditBox it generates a new form with buttons and with the edit box. On pressing the enter key the the value is copied to the edit box that called this form. Ok, now I have made the form like in the post above, but one thing that needs structured programming skills I can't do is how to make this form read the text and how to tell the form when destroying or exiting to send text to the object that called the form.

thanks, Marko

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Touch screen keyboard
« Reply #3 on: August 07, 2011, 06:57:02 pm »
I have soon noticed that it uses Windows, perhaps there are some extra function that could be deleted for non-windows user.
There is nothing Windows specific in two forms calling each other. If you follow instructions exactly code will work at least on Win/Lin/Mac. EDIT: I see now that you may have been referring to Delphi component I mentioned.

Quote
how to make this form read the text and how to tell the form when destroying or exiting to send text to the object that called the form.
Do exactly as I wrote before here:
Quote
make two buttons like 'Finish' and 'Cancel'. Both will close the dummy form, but first will also copy Edit string from dummy form to your main form.
On both buttons OnClick events put 'Hide;' commands that will hide your VirtKeyb (dummy) form . On 'Finish' button also put single line before Hide which will copy text from Edit box of VirtKeyb form to Edit box of caller form. That's it, but everything is hard coded. Once it works, you can think about this sentence:
Quote
In order to make this universal, you will have to provide caller info to the dummy form, so any Edit on any form in your application can call your dummy form.
Once you get over that, you should think about positioning of VirtKeyb form - is it fixed or it depends on the position of the caller Edit box.
« Last Edit: August 07, 2011, 07:00:36 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

 

TinyPortal © 2005-2018