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

SelectOnEntry

Status
Not open for further replies.

fy123

Programmer
Feb 28, 2007
3
0
0
GB
I have some text boxes with SelectOnEntry set to .T.
It works with the arrow or tab key but NOT if the MOUSE is used to get focus.


Any help?

Frank
 
Yup.

I use the gotfocus event.

Put something like this in it:

Code:
	THIS.SELSTART = 0
	THIS.SELLENGTH = 100

It's probably overkill, but it works.

To be 100% sure put this in the click event too:

Code:
	THIS.SETFOCUS

Good luck

Regards

Griff
Keep [Smile]ing
 
I have some text boxes with SelectOnEntry set to .T.
It works with the arrow or tab key but NOT if the MOUSE is used to get focus.

This is the default windows behavior. If you want to change it, you need code like this in the GotFocus() of your control:

Code:
WITH This
  IF .SelectOnEntry
    Textbox::GotFocus()
    .SelStart = 0
    .SelLen = LEN( .Text )
    NODEFAULT
  ENDIF
ENDWITH

The reason you need to write the code like this is that, by default, VFP will run any custom code you have in a method and then do the native VFP code afterward. The native VFP behavior of GotFocus() is to reset selStart and SelLength. So, the code above uses the scope resolution operator to execute the native VFP code before setting these 2 properties and NODEFAULT afterward to supress this native behavior.





Marcia G. Akins
 
Hello Marcia,

...and then, you still might want to DODEFAULT() somewhere.

Bye, Olaf.
 
It's important to remember that if you select on entry with the mouse, the user will no longer be able to use the mouse to place the insertion point at a particular place. They would have to use the arrow keys to do that, which they might find inconvenient.

That's probably why the default Windows behaviour is not to select on entry with the mouse. Personally, I would keep it that way.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hi Mike,

I think that's why Marcia has Textbox::GotFocus() in her code.

No, I'm thinking of a case, where you already use a textbox class and subclass this subclass of the native textbox.

Textbox::gotfocus() calls the native textbox behaviour,
DODEFAULT() calls code in the parent class. These are different things.

Bye, Olaf.
 
Thank guys. I get the idea.

One more thing. On a page frame, when a page tab is clicked the text selection doesn't work on the field that gets focus. This only happens the first time I go to the page. Subsequent movement to the page poses no problem.

Thanks
 
On a page frame, when a page tab is clicked the text selection doesn't work on the field that gets focus.

In the page's Activate, programmatically set focus to the first field. Something like this:

THIS.txtField.SetFocus


Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
i have used
KEYBOARD '{CTRL+A}'
in the gotfocus a textbox containing numbers to select the entire number and type it quickly all over again, changing the whole number instead of having to place the insertion point and change a number value
wjwjr
 
I put these code in the GotFocus event of my textbox class :

IF VERSION(5) < 900
DODEFAULT()
ELSE
IF !UPPER(TRIM(This.Parent.BaseClass))=='COLUMN'
This.SetFocus
NODEFAULT
ENDIF
ENDIF

It work great : First click highlight whole value and second click place cursor on your desired insetion point
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top