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

Strange Form Behavior

Status
Not open for further replies.

pweegar

Programmer
Joined
Nov 3, 2000
Messages
403
Location
US
Hope someone can help with this. We develop apps in VFP 6.0 under Win2k. I have a form with 2 option groups that populate 2 text boxes. I also have a third text box whixh is editable. When a user clicks on one of the option buttons in optiongroup1, the coresponding textbox is update, a setfocus is fired to go to the next optiongroup. Again the user makes a selection and the text box is filled. When using the mouse or space bar, the focus is then put on the third textbox (which allows the user to enter a date). After a date is entered, focus is set to a command button to save the data. I have checked and re-checked the tab stops and they are in the proper order. Now the strange behavior. When the user presses the ENTER key, focus moves from optiongroup1 to optiongroup2 and populates the text boxes as expectred. However when pressing the ENTER key from optiongroup2, focus is passed to my command button (to save data) bypassing the last textbox.

Has anyone else seen this? Is there a workaround? My users are acustomed to using the enter key and don't want to be forced to use the spacebar or mouse. Thanks in advance.
 
Does it have anything to do with the tab order properties of your objects?. If the tab order of the objects are different from where your code is telling the focus to go I have seen in rare cases that it will override your code and do what it wants.
 
I would think that if the tab indexes were being overridden by the set focus, the behavior would result whether the user used the mouse, pressed the space bar or pressed enter. I would also suspect that it wouldn't matter what type of control the set focus was set to fire next. The behavior is ONLY seen when a user presses the ENTER key, from an option group expecting to jump to a text box, not a command button. In any event, I double checked my tab oreders and the textbox (txtDate) is next in order after OptionGroup2 and before my command button.

Pressing ENTER from optiongroup2.option1 SHOULD take me to txtDate. However when pressing ENTER, the focus moces to my cmdLoad button, completely bypassing the txtDate box.

Using the mouse or space bar, the set focus works properly.
 
Does your command button have the Default property set to .T.? (Any button with this property set?) If it does, it will alway go to this button when the Enter is pressed unless there is an overriding SetFocus().

Rick
 
Just checked my command buttons. All are set to Default =.F.
 
HI
The reason is that when you press enter, you choose the next option of an option group as default. However, you are forcing a lostfocus. The option group is not having a lostfocus event as an event.

SO your forcing the lost focus might be getting transferred to the textbox, if you are stuffing the keyboard to get a tab effect in addition to the KEYBOARD enter which also might have the same effect.

If this tip is not leading you to the solution, you can post the full code used to give the lost focus effect. May be a solution can be posted by any one of us.
:-)


:-) ramani :-)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
pweegar,

It would be strange to bypass your txtDate box if 'Enabled' is set to .t. unless it is .f. Can you double check?

Peping
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top