Index
2001-10-09 13:42Dan Covill : Re: Auto-select text in editbox
2001-10-09 15:07Michael Babcock : Auto-select text in editbox
2001-10-09 15:10A Hilton : RE: Auto-select text in editbox
2001-10-09 15:40Paul McNett : Re: Auto-select text in editbox
2001-10-09 15:47Paul McNett : Re: Auto-select text in editbox
2001-10-09 16:35Charlie Coleman : RE: Auto-select text in editbox
2001-10-09 18:08Bill Kressbach : Re: Auto-select text in editbox
2001-10-09 20:16A Hilton : RE: Auto-select text in editbox
2001-10-09 20:48Barbara Peisch : Re: Auto-select text in editbox
2001-10-10 07:28A Hilton : RE: Auto-select text in editbox
Back to top
Re: Auto-select text in editbox

Author: Dan Covill

Posted: 2001-10-09 13:42:18   Link

Michael:

As I recall, the 'K' works if you tab/enter into the box, but not if you

click on it. The cure (I believe) is to put the following into the

GotFocus() method:

this.SetFocus()

Weird, but it works.

Dan Covill

Middleton Consulting, San Diego

At 15:07 10/09/01 -0400, Michael Babcock wrote:

>Ok, I've got an editbox with Format="K" and it's not selecting all the text

>when I set focus to the box!!! Argh!

>

>How can I programatically do this in the GotFocus event of the editbox???

>

>TIA,

©2001 Dan Covill
Back to top
Auto-select text in editbox

Author: Michael Babcock

Posted: 2001-10-09 15:07:13   Link

Ok, I've got an editbox with Format=3D"K" and it's not selecting all the text

when I set focus to the box!!! Argh!

How can I programatically do this in the GotFocus event of the editbox???

TIA,

Michael J=2E Babcock, MCP

Keystone Peer Review Organization

vfpmcp@hotmail=2Ecom

www=2Evfpdevassoc=2Eorg

"Work smarter; not harder=2E"

=20=

=20=

=20=

=20=

=20=

=20=

=20=

=20=

=20=

=20=

=20=

©2001 Michael Babcock
Back to top
RE: Auto-select text in editbox

Author: A Hilton

Posted: 2001-10-09 15:10:29   Link

You could do a:

keyboard '{END}'

keyboard '{HOME}'

keyboard '{SHIFT+END}'

and it *might* work. I say *might* because there are cases where it doesn't

work (like having a textbox/editbox contained in a container class that's

programmatically added to a grid ... in which case NOTHING works to

auto-select text reliably). I'm sure there are other methods to achieve what

you want, but my brain is mush at the moment having had the pleasure of

debugging a chain of MS Exchange Servers all morning (F#*&!!##KIN#@##@!).

- AHilton

> Ok, I've got an editbox with Format="K" and it's not selecting

> all the text

> when I set focus to the box!!! Argh!

>

> How can I programatically do this in the GotFocus event of the editbox???

>

> TIA,

>

>

> Michael J. Babcock, MCP

> Keystone Peer Review Organization

> vfpmcp@hotmail.com

> www.vfpdevassoc.org

> "Work smarter; not harder."

©2001 A Hilton
Back to top
Re: Auto-select text in editbox

Author: Paul McNett

Posted: 2001-10-09 15:40:38   Link

On Tuesday 09 October 2001 01:10 pm, A Hilton wrote:

> You could do a:

>

> keyboard '{END}'

> keyboard '{HOME}'

> keyboard '{SHIFT+END}'

>

> and it *might* work. I say *might* because there are cases where it

> doesn't work (like having a textbox/editbox contained in a container class

> that's programmatically added to a grid ... in which case NOTHING works to

> auto-select text reliably). I'm sure there are other methods to achieve

> what you want, but my brain is mush at the moment having had the pleasure

> of debugging a chain of MS Exchange Servers all morning

> (F#*&!!##KIN#@##@!).

I'd like to suggest using SelStart and SelLength. I just made a pretty

spiffy status bar utilizing an editbox which automatically selects the newest

status message. In my case I set that editbox property (what property was

that again? <g>) that keeps the text selected even when the control doesn't

have the focus. It works without a hitch.

You can also look at the SelectOnEntry Property, but I've had weird results

relying on that in the past.

--

Paul McNett

Hollister, CA USA

©2001 Paul McNett
Back to top
Re: Auto-select text in editbox

Author: Paul McNett

Posted: 2001-10-09 15:47:48   Link

On Tuesday 09 October 2001 01:42 pm, Dan Covill wrote:

> As I recall, the 'K' works if you tab/enter into the box, but not if you

> click on it. The cure (I believe) is to put the following into the

> GotFocus() method:

> this.SetFocus()

I find that calling SetFocus() is pretty intensive performance-wise. There

is always a substantial delay after calling it. I avoid it like anthrax.

IMO the KEYBOARD solution would be much faster.

I used to avoid doing the KEYBOARD thing because I thought that it was

non-OOP, but I've found that most things will happen so much faster in VFP

using KEYBOARD versus the obvious OOP way.

--

Paul McNett

Hollister, CA USA

©2001 Paul McNett
Back to top
RE: Auto-select text in editbox

Author: Charlie Coleman

Posted: 2001-10-09 16:35:14   Link

As one more suggestion, you may want to check out the "SelectOnEntry"

property. I haven't messed with it much myself. I've normally used the

below suggestion. But since the property is there, I thought I'd mention it.

HTH,

-Charlie

>You could do a:

>

>keyboard '{END}'

>keyboard '{HOME}'

>keyboard '{SHIFT+END}'

>

>and it *might* work. I say *might* because there are cases where it doesn't

>work (like having a textbox/editbox contained in a container class that's

>programmatically added to a grid ... in which case NOTHING works to

>auto-select text reliably). I'm sure there are other methods to achieve what

>you want, but my brain is mush at the moment having had the pleasure of

>debugging a chain of MS Exchange Servers all morning (F#*&!!##KIN#@##@!).

>

>- AHilton

>

> > Ok, I've got an editbox with Format="K" and it's not selecting

> > all the text

> > when I set focus to the box!!! Argh!

> >

> > How can I programatically do this in the GotFocus event of the editbox???

> >

> > TIA,

©2001 Charlie Coleman
Back to top
Re: Auto-select text in editbox

Author: Bill Kressbach

Posted: 2001-10-09 18:08:32   Link

Here's how I do it. Somewhere in your startup code define the variable

"plselect" make it public and set it to .F.

In the GotFocus event put:

this.SelStart=0

this.SelLength=len(this.value)

plSelect=.T. &&_Mark that object is selected

In the MouseUp event put:

if plSelect

this.SelStart=0

this.SelLength=len(this.value)

plSelect=.F.

endif

Kind of a pain but it's always worked for me.

Bill

> Ok, I've got an editbox with Format="K" and it's not selecting all the

text

> when I set focus to the box!!! Argh!

>

> How can I programatically do this in the GotFocus event of the editbox???

©2001 Bill Kressbach
Back to top
RE: Auto-select text in editbox

Author: A Hilton

Posted: 2001-10-09 20:16:04   Link

> I'd like to suggest using SelStart and SelLength. I just

The problem, as I vaguely remember it, wasn't that the text wasn't actually

selected (using the selectonentry property for when the user keyboards onto

the control; using the KEYBOARD commands within the Gotfocus event when the

user mouses onto the control) but the visual blue-text-selected-clue wasn't

there showing the user that all the text was, indeed, selected but only when

the user keyboarded onto the control. The control showed all text selected

correctly when the user would mouse to it though. The control simply showed

no visual clues at all that it had focus. I tried using the

SelStart/SelLength stuff too and it behaved the same way.

I believe I got around that particular problem by manually changing the

backcolor property of the control during gotfocus and changing it back again

in lostfocus.

I had all kinds of problems with this clients' UI demands (seeing many

fields for each record in a grid at the same time without horizontal

scrolling) on this form. It was a fun one!

- AHilton

©2001 A Hilton
Back to top
Re: Auto-select text in editbox

Author: Barbara Peisch

Posted: 2001-10-09 20:48:18   Link

> GotFocus() method:

> this.SetFocus()

Careful with that. If you've gotten to this textbox via a Valid method

anywhere up the chain, that will barf on you. Instead, just put Dodefault()

in the GotFocus method. I also only call Dodefault if SelectOnEntry is .T.

That still won't work when you click in the textbox if it's in a grid,

though. So, in the Click method, I put this code:

If This.parent.class = "Column" and this.SelectOnEntry = .T.

Dodefault()

This.SelStart = 0

This.SelLength = 999

Nodefault

Endif

Of course, if your textbox is wider than 999, you'd have to increase the

setting of SelLength.

-BP

www.peisch.com

©2001 Barbara Peisch
Back to top
RE: Auto-select text in editbox

Author: A Hilton

Posted: 2001-10-10 07:28:54   Link

This discussion got me interested again in exactly what the problem with

this was so I dug out that clients' project from the archives (they aren't

an active client right now). The problem really was as I decribed before.

It seems that your solution works here, Andrew! A few quick tests later and

some swapping of my previous attempts at solutions (I save almost everything

when I have unresolved problems like this as commented-out code so I can

come back to it later) using the other methods mentioned before and it seems

like yours works consistently in my situation. Very good!

Thanks,

- AHilton

> You could try the following

>

> keyboard chr(1)

>

> it seems to work for me.

>

> Regards,

>

> Andrew

©2001 A Hilton