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

Cursor Movement in VFP6.0

Status
Not open for further replies.

EzLogic

Programmer
Aug 21, 2001
1,230
US
I am new to FoxPro (I use Clipper). Can anyone tell me how to make the cursor stop @ the end of each field in the form. I used the [SET Confirm ON] and it helps, but still, if the user presses the <- or -> the field looses the focus. I want the user to stay in the field, except when he/she presses Enter or Click on another field in the form....

Your help is appreciated.

TeknoSDS
akoumaiha@hotmail.com
 
You need to put code in the lostfocus or valid events of the object to see if it's ok to move. But you may have to set something up to trap any keys you don't want to be operational like the arrow keys and this would involve the keypress event. I'll let people more experienced in such things direct you on what to put in the events, however. -- Dave Dardinger
 
Thge arrow keys normally move you from field to field so you are going to have to trap the keystrokes. If you are using VFP, look at the forms keypress event and trap the keystrokes you will need to set the forms keypreview property to true so the form gets the keystroke before the control. All that being said why are you doing this? Using the arrow keys to move around a form is pretty much a windows standard.
 
Thank you Dave and Flute. The reason I want this is because, @ my office, I have 2 data entry girls. And when they type they don't look @ the screen (they look @ the papers). So, sometimes, they move to the end of the field and they press the left or arrow key to navigate within the field. As a result, VFP moves the cursor to the next field and they override the value in the field by mistake.

I will try the keypress event and the keypreview. If it doesn't work, I will let you guys know!!!!

Thank you guys
Tekno
 
I'm not sure if it still works in VFP but there used to be a SET CONFIRM ON.

Do you want to ring the bell to warn them if they move into that another field.
?? chr(7) on the lostfocus of the field you are leaving or when of the other field
 
Peto, I do use the Set confirm on (Just like the Clipper Version). It helps. But, when the user presses the Backspaces and the cursor reaches the end of the field, the cursor jumps to the previous field. Or when the user presses the space bar, same thing. The [Set Confirm ON] only helps me when the user types and reaches the end of the field, the cursor doesn't move. But, this is kinda bad, since the user can override values in other fields without any intentions to do so.

More help from some experts?

Thanks
Tekno
 
I have at times used the following as a shortcut:

KEYBOARD('{HOME}')

In the Grid->Column?->Text?->Gotfocus event.
This acts the same as pressing the 'HOME' key. Upon entering a field, the cursor is immediately sent to the beginning of the text. I know there is a way to do it more elegently but sometimes I do use this way.

Dave S.
 
You could also set up ON KEYLABEL statements to trap certain keystrokes. You could do that in the Init or Activate event of the form and then you can basically cause the keyboard to do whatever you want.

-- CDavis
 
Dave, if the user is already @ the beginning of the text, which he is, so what happens when he presses the backspace!!!!!! The cursor will navigate to the previous field, right? According to the Tab Order Setting!!!
I need to trap the cursor in the field box. (I don't want to use the Valid event or the keypress event for every field) I have about 50+ fields, you know!!

Tekno
 
I need to trap the cursor in the field box. (I don't want to use the Valid event or the keypress event for every field) I have about 50+ fields, you know!!

Don't worry too much about how much code you need to write to get a field to do what you want. Just get one to act as you want and then save it as a class. Now you can use the class for any field you want to behave in the same manner. The only thing you'll have to watch is making sure you don't encapsulate something you want exposed. If so, you may have to create a class property to expose it.

Dave Dardinger
 
I will try that dave. Your help is appreciated, and I will give you the feedback on how it went.

Tekno
 
May I suggest the following code in your VALID fields.

if lastkey()=13
return 1
else
return 0
endif

The field will only lose the focus when RETURN is pressed.

Keith
 
Hi TeknoSDS,

Sorry I did not see that you have not succeeded. The answer is very simple.

Put the following code in the

myGrid.BeforeRowColChange Event
*******************************
IF LASTKEY() = 4 OR LASTKEY() = 19
NODEFAULT
ENDIF

This is sure to work.

ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top