Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to select textbox when mousing in
Message
From
05/11/2003 21:40:25
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00846750
Message ID:
00846911
Views:
41
Well, I'm humbled. ;)

Alan

>>>>>>>If you have a textbox set up to select upon entry, and then click into that textbox with your mouse, the textbox loses its highlight and the cursor positions to the column in the textbox where you clicked. Is there any way to have the textbox work the same way with a mouse click in it as it does if you tabbed into it? I want it to select the entire length of the textbox and be ready for input from the left side, replacing any data in it with what I type in.
>>>>>>>
>>>>>>>Jim White
>>>>>>
>>>>>>You can put this in the Click of the TextBox:
>>>>>>
>>>>>>this.SelStart = 0
>>>>>>this.SelLength=LEN(ALLTRIM(this.Value))
>>>>>>
>>>>>
>>>>>Excuse me for jumping in but if the controlsource is not a charater this will generate an error.
>>>>
>>>>Sure could.
>>>
>>>Change it to This.Text instead of This.Value and that problem goes away.
>>>
>>>Alan
>>
>>You know, between the 3 of us, we might get this nailed down. ;)
>
>Let me join your tight group. :)
>
>That is what you can do using some lateral thinking :) beside the obvious Click() and SetFocus() events. :)
>
>The extended features of the Left Mouse click :)
>
>1. One short click selects the whole textbox value
>2. You still can do the manual text selection in the box
>3. If you click and hold the mouse for more than one second, the cursor will stay where you clicked and you still can do the normal editing.
>4. As a bonus :) DoubleClick selects the existing text and the trailing spaces (but not the leading spaces (if any).
>
>
>*** MouseDown() event
>LPARAMETERS nButton, nShift, nXCoord, nYCoord
>this.WhatsThisHelpID = INT(SECONDS())
>
>***MouseUp() event
>LPARAMETERS nButton, nShift, nXCoord, nYCoord
>IF nButton = 1
>	DO CASE
>		CASE ABS(INT(SECONDS()) - THIS.WHATSTHISHELPID ) > 1 && 1 sec delay
>			* do nothing - leave the mouse pointer where it landed allowing to position within the textbox
>		CASE THIS.SELLENGTH = 0
>			THIS.SELSTART = 0
>			THIS.SELLENGTH = 1000
>		CASE THIS.SELLENGTH > 0
>			* Leave the selection made as is
>	ENDCASE
>ENDIF
>
>
>I employed the rarely used WhatsThisHelpID property to hold the SECONDS() value just for example. Of course you can use a custom property for that.
>
>I used THIS.SELLENGTH = 1000 for the whole text selection to avoid unnecessary function calls.
>
>Using THIS.SELSTART = 0 and THIS.SELLENGTH = LEN(ALLTRIM(this.Value)) or THIS.SELLENGTH = LEN(ALLTRIM(this.Text)) is not reliable if the textbox value has the leading spaces.
>
>Just having some fun this afternoon... :)
Previous
Reply
Map
View

Click here to load this message in the networking platform