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

Form Set Focus Question

Status
Not open for further replies.

crewchiefpro6

Programmer
Mar 22, 2005
204
US
I have one form that the focus jumps to the command button each time I press enter or tab. I have set the tab order just like every other form but this one behaves different.

I would like the focus to move to the next text field in the tab order. Any ideas?



Don Higgins
 
Search all the form's methods for commands ("setfocus" etc.) refering to that button?

 
Even when I remove any method it still does this. When I have it on debug, and the valid fires (nothing but return in the method), the calling program pops up in the Debugger with the line

do form statistics

Which has already been called by the menu. The form is modal.



Don Higgins
 
Hi Don,

the debugger will display the DO FORM line, because actually no code runs and that code was the last executed. As the form is modal, this is quite normal. If you had no modal form running, the line could be the READ EVENTS line.

The .Default property would set the focus behaviour quite the way you describe it: That control will be triggered by ENTER or RETURN or STR+ENTER/RETURN (but not TAB). The .Cancel property set .T. would let the control react to ESC.

Look up the Default and Cancel properties for further details.

Other reasons, a control doesn't get focus is, it's disabled (Enabled = .F.), then the TAB could trigger to set the focus down the line of controls in .Taborder until it finds an enabled control, which may always end at the button. (.Readonly may be the better option to let a control being "focusable" but it's value writeprotected). And a control can refuse focus in the When()-Event by returning .F. there.

Also a control may set the focus not to the next but the second next control by returning 2 (or some other number, negative will backtab) in it's Valid event or to some known control with the Setfocus()-Method.

Bye, Olaf.
 
The controls are just text boxes. This is the only screen I have ever designed that acted this way. Enabled is .t. in all controls. There is no redirect in the code but each time I press enter it goes to the first control in the tab order.

Another note is I cannot tab out of the command buttons! I have never seen anything like this either. NO Code is on the buttons except thisform.release on the exit button.



Don Higgins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top