Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

lastkey() function as in clipper

Status
Not open for further replies.

Pontelo

Programmer
Dec 18, 2001
80
BR
Is there some function that acts as lastkey() function in old clipper ? I would like some kind of function, ie., one that you can call any time anywhere while running the system.
Thanks
 
You can come close:

Create a global variable called (e.g.) LastKey
Then set KeyPreview to True in your form properties.
Finally trap the KeyPress event like this:
Code:
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
  LastKey := Key;
end;
Anytime you need the last key, it's there in the global var.

For example:
Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text := LastKey;
end;
 
Zathras
Thank you.I thought we had some function we can access instead of writing code to every form where we eventually need this.
 
There may very well be. There are so many functions in so many units it is nearly impossible to know them all.

But I'm curious. I have never had a requirement for such a function that I can recall in the past 30 years. Can you provide an example of why you feel this is needed?

 
We have a system written in clipper. It have 8 years and a lot of customers. Like all DOS system, it has a lot of hotkeys - and our customers are familiar with them. I´m an old clipper programmer too. So, as I rewrite modules, the hot keys used today go together. LastKey is quite usefull qhen you treat hotkeys. I found a component called DOSMOVE, from IBM´s guys. One component per form, and it transform TABS and arrow up and down to ENTER as we are familiar. I´ve implemented LastKey on it, as a property, before install it. I´m testing, but seems to run OK. I´m Delphi novice. Probably i´ll change many ways to do things along the time (at least i hope so !). Besides, in Business System, TAB is not productive, since users are most of the time using numeric keyboard.
Excuse my bad english.
 
enonod,
that function is to check if event came from keyboard or mouse
it´s something like you say isFromKeyboard() or isFromMouse().
I think this problem was solved with DOSMOVE component.
Thank you anyway for your attention.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top