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

problem with cursor positioning

Status
Not open for further replies.

Judi201

Technical User
Jul 2, 2005
315
US
Hi!

I have a form calling a modal form to get a number and check to see if valid and return to calling form. There I append blank, set values for the first three fields and refresh the screen. The cursor should hold on the fourth field but jumps to the nineth. I have checked tab order and any code in the fields and all seems right. All fields are bound to the table. I have tried SETFOCUS from many places. Is there any way that I can force the field to hold the cursor.

In debug, it initializes in the correct order, just doesn't stop. Any suggestion appreciated.

Thanks
Judi
 

Hi Judi,

Are you saying that, if you do this:

THISFORM.Field4.SetFocus

then focus goes to Field9?

If so, the only explanation that springs to mind is that Fields 4 to 8 have got code in their When events, and this code is returning .F.

(Assuming the fields are enabled, of course).


Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Marcia, Mike, Thanks for the response.

Marcia: I am issuing the SETFOCUS() in a method that Adds a new record. The same code that calls the modal form. Basically,
Call form
catch parameter
append blank
set first three fields
set the focus on the fourth field
refresh the form to continue adding info.

I had expected the cursor to go to the fourth field (next in tab order) but used SETFOCUS() when it did not. How would I use NODEFAULT here?

Mike: Yes, that is exactly what I mean. The only code in any of the fields is in the GOTFOCUS for two date fields (number 6 & 7) but I removed that. No change.

Appreciate any thoughts.

Judi
 
Marcia,

I might need to mention that my textboxes are based on your classes from '1001 Things...' if maybe that might make a difference. When I say 'no code' I mean none added here.
However, I use them on all screens and have never seen this before.

Judi
 
I might need to mention that my textboxes are based on your classes from '1001 Things...'

Are you using the numeric textboxes here? They may have some quitky behavior.

Rather than posting pseudo code, why don't you post the actual code that you are using in this method?


Marcia G. Akins
 
Marcia,
Yes, fields 4-7 are txtbase and field 8 is txtnumeric based. The cursor stops on field 9. As I said earlier, I use some of these on every screen and have never had any problems and love the control of the decimal point. I am at a loss. I am still working in vfp 6.0 but have 9 installed and ready to move to. I was trying to solve a few nagging problems before trying it on 9 as I am sure that will present its own set of problems.:)

Code:
 IF EMPTY(Thisform.cReturnValue) 
			*** effort failed 
			RETURN
		ELSE
			*** got a new one - add record
			Thisform.lockscreen = .T.
			Thisform.ChkJob()   && get custno,partnumb 
			SELECT orders
			APPEND BLANK
			REPLACE orders.jobsnumb WITH Thisform.NewJobno
			REPLACE orders.partnumb WITH Thisform.NewPartno
			REPLACE orders.custno   WITH Thisform.NewCustno 
			Thisform.ShowOrdrScrap()
			Thisform.ShowProdStatus()
			SET ORDER TO TAG jobsordr
			Thisform.pgfCasting.pagOrders.txtOrderno.SetFocus()
			Thisform.pgfCasting.pagOrders.Refresh()
			Thisform.lockscreen = .F.
		ENDIF

I am at a loss, ANY thoughts would be appreciated.

Judi
 
Judi,

I suspect that moving the SetFocus call to the last line of that code block, after the form Refresh() and turning off the LockScreen, will solve your problem.

Regards,
Jim
 
Jim,

Thanks so much for the response.

I suspect that moving the SetFocus call to the last line of that code block, after the form Refresh() and turning off the LockScreen, will solve your problem.

Do you mean not use LockScreen at all?

Judi
 
Mike,

I changed it to this with the same result.

Code:
	*** got a new one - add record
			Thisform.ChkJob()   && get custno,partnumb 
			SELECT orders
			APPEND BLANK
			REPLACE orders.jobsnumb WITH Thisform.NewJobno
			REPLACE orders.partnumb WITH Thisform.NewPartno
			REPLACE orders.custno   WITH Thisform.NewCustno 
			Thisform.ShowOrdrScrap()
			Thisform.ShowProdStatus()
			SET ORDER TO TAG jobsordr
			Thisform.pgfCasting.pagOrders.Refresh()
			Thisform.pgfCasting.pagOrders.txtOrderno.SetFocus()

Thanks for any thoughts. I know this is like pulling a goldfish from a bowl blindfolded from your end. But I will appreciate any ideas.

Judi
 
Judi,

Where is this code? Is it by any chance in a Valid method?

Regards,
Jim
 
Hi Judi.

Yes, fields 4-7 are txtbase and field 8 is txtnumeric based. The cursor stops on field 9.

OK - I suspect that the problem is txtNumeric. When I started using it in production apps, I encountered some bugs. I have an updated version of the control that I am using and I can send it to you.



Marcia G. Akins
 
Jim,

It is in a METHOD of my EditNavBar on the base form.

In just looking for something- ANYTHING, I changed the SetFocus() to the first field and the same thing happens. If I remove the 9th field, it skips one and stops on the 11th field. Has a mind of it own![sad]

Judi
 
Marcia,

Thanks so much for your help. I changed the txtnumeric to a base textbox and the behavior did change. Now the cursor goes farther past the field.

Before making any of the last changes, I had determined that the cursor stopped four fields past where I set the focus. I deleted the field it stopped on and it moved two fields past it. After changing the numeric textbox it goes five fields past. When I set the focus on different fields, moving forward in the tab order, the stop position moved four past it each time. Now when I change the focus it jumps forward by different amounts but always forward. Time to call the men in white coats with 'jackets'!

I have no idea what to try now. I am moving on to 9 but don't expect that to help this problem.

Thanks to anyone for any idea that I can try.

Judi
 
Thanks so much for your help. I changed the txtnumeric to a base textbox and the behavior did change

OK - that rule sout the numeric text box as the culprit. So it must be something in your code.

You are going to have to put a breakpoint right before the SetFocus() and see what is happening.



Marcia G. Akins
 
Hi Judi
I think You can change your steps in code
At First Text field in Valid
you have eg:
SELECT ufo
APPEND BLANK
REPLACE text1 WITH 'xxxx'
REPLACE text2 WITH 'xxxx2'
REPLACE text3 WITH 'xxxx3'
and eg.
replace text9 with 'YYY'
So no matter how many fields have You autofill
than
thisform.Refresh

And
than in
LostFocus on this First Field
thisform.txtNum4.SetFocus

That automatically goes to 4-th fields

I think thats will be work



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top