Stop backspace in VFP

Posted on April 4, 2005. Filed under: Visual FoxPro |

Here’s a tip Scott Scovell informed me of regarding a non-standard VFP behaviour:

‘I had a request from a client to prevent the textbox from losing the focus when they use BACKSPACE.

When removing details from a textbox using the BACKSPACE key, focus was being transferred to the previous textbox and they (more often then not) began to remove details from that textbox as well.

Windows standard

The standard behaviour appears to be that when using BACKSPACE, focus is not transferred to the previous control in the tab order. Try this creating a New email in Outlook and setting focus to the CC field. Using BACKSPACE observe that the control does not lose focus. FoxPro does lose focus and the previous control in the tab order get focus.

Solution

Surprising easy. In the Valid, test for LastKey() = BACKSPACE and This.Value is Empty() then return false (deny lose focus)

* Deny loss of focus when the backspace key is pressed and the control has an empty value
If Lastkey() = 127 And Empty(This.Value)
Return .F.
EndIf

* other checks etc…
Return .T.

Advertisements

Make a Comment

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

One Response to “Stop backspace in VFP”

RSS Feed for Craig Bailey on Microsoft Comments RSS Feed

it works fine if the user is working with keyboard only but after deleting if users wants to go to another field by mouse then it is not possible.


Where's The Comment Form?

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: