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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOT FUNCTION KEY PROBLEM

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
If you define a hot function key (using on key or key event) say F8, when a user presses that key while on a text field, after the called routine returns successfully an extraneous (F8) character is entered on the field. How do I disable that? Thanks.
 
try KEYBOARD CLEAR before returning from routine Attitude is Everything
 
I can't duplicate your problem. sorry Attitude is Everything
 
It depends on what your called routine is or returns. If you have a textbox on a form, and you define your F8 key as something like:

ON KEY LABEL f8 SomeForm.Text1.Value = getfile()

This will fill the textbox with a file name.
Dave S.
 
I tried that too and unfortunately the statement will return a weird error something like "SomeForm can only be used within a method" (where else do we enter our code! outside a moethod?). The routine basically clicks a command button which then asks the user whether he wants to terminate what he is doing. If he does no problem because it releases the form. But if he says no, i.e. resume entering data, that's when the F8 character is entered.
 
ON KEY LABEL f8 SomeForm.Text1.Value = getfile()

'SomeForm' must be an object reference, not THISFORM or a form name HTH

Chris [pc2]
 
How do I post form and data so I can show you guys what I am doing? Thanks.
 
SomeForm is this. If from the command window you do something like:

DO FORM SomeForm
Chris is right. You can't do:

ON KEY LABEL f8 ThisForm.BlahBlah

Because when the key is pressed, you are not executing form code. The F8 key isn't a form. So it needs to reference the form object explicitly.

You can cut and paste the code for your F8 button here. Chances are we'll be able to tell a great deal from that.
Dave S.
 
OK. Here it goes.

This is the code in the thisform.init:

ON KEY LABEL f8 thisform.voidTransaction.Click

This is my code in thisform.voidTransaction.click


DO FORM confirm WITH 'Are you sure you want to void this transaction?' TO releaseIt
IF releaseIt
thisform.Release
ENDIF

The form confirm is just a generic form which returns either .T. or .F. Thanks again.
 
So you need to replace "thisform" with the name of your form. Also, you need to make sure 'releaseIt' is not losing scope. I.e., global or public in the Init of the first form.
Dave S.
 
BTW, I also tried this:

DO FORM confirm WITH 'Are you sure you want to void this transaction?' TO releaseIt
IF releaseIt
thisform.Release
ELSE
thisitem.setfocus && refocus field before F8 was pressed
KEYBOARD '{BACKSPACE}'
ENDIF

It works in a way. But if the user had already typed in some characters, it deletes the whole field instead of just the F8 character.
 
Thanks guys. It took me sometime to realize the difference between formname and thisform. You all have a good one!
 
Yo would be much better off not using an OKL at all, and putting the code in the forms keypress event. You would also need to set the forms keypreview property to .t., this allows the form to see the keypress before the controls on the form see it.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top