Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SelectOnEntry and TextBox::GotFocus
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01014284
Message ID:
01014289
Views:
27
This message has been marked as a message which has helped to the initial question of the thread.
I can't take credit for the code below. It's from Drew Speedie in his Visual MaxFrame Professional product. Apparently SelectOnEntry has NEVER worked with a mouse and so you would have to "trick" it like you did by putting in a explicit call to textbox::GotFocus(). That strategy unfortunately stopped working in VFP9 for some reason. So the code below in the Click() of a text box will get it to work like you expected:

--Brad
PROCEDURE text1.Click
IF NOT VARTYPE(THIS.ilMouseDownOnGotFocus) = "L"
  ADDPROPERTY(THIS,"ilMouseDownOnGotFocus",.T.)
ENDIF
IF THIS.ilMouseDownOnGotFocus ; 
     AND (THIS.SelectOnEntry OR "K" $ UPPER(THIS.Format))
  LOCAL lnSelLength
  THIS.SelStart = 0
  IF VARTYPE(THIS.Value) = "C" ;
      AND LENC(THIS.InputMask) <= LENC(THIS.Value)
    lnSelLength = LENC(ALLTRIM(THIS.Value))
   ELSE
    lnSelLength = 999
  ENDIF
  THIS.SelLength = m.lnSelLength
ENDIF
THIS.ilMouseDownOnGotFocus = .F.
ENDPROC
>With VFP8 the code below works perfect. When I click on text? he is selected.
>
>But with VFP9 when I click with mouse on textbox? he is not selected.
>
>I don't understand where is my mistake.
>
>
PUBLIC oform1
>
>oform1=NEWOBJECT("form1")
>oform1.Show
>RETURN
>
>DEFINE CLASS form1 AS form
>
>
>	Top = 0
>	Left = 0
>	Height = 123
>	Width = 319
>	DoCreate = .T.
>	Caption = "Form1"
>	Name = "Form1"
>
>
>	ADD OBJECT text1 AS textbox WITH ;
>		Alignment = 3, ;
>		Value = 0.00, ;
>		Height = 25, ;
>		Left = 34, ;
>		SelectOnEntry = .T., ;
>		Top = 27, ;
>		Width = 81, ;
>		Name = "Text1"
>
>
>	ADD OBJECT text2 AS textbox WITH ;
>		Alignment = 3, ;
>		Value = 0.00, ;
>		Height = 25, ;
>		Left = 163, ;
>		SelectOnEntry = .T., ;
>		Top = 27, ;
>		Width = 81, ;
>		Name = "Text2"
>
>
>	PROCEDURE text1.GotFocus
>		TextBox::GotFocus
>	ENDPROC
>
>
>	PROCEDURE text2.GotFocus
>		TextBox::GotFocus
>	ENDPROC
>
>
>ENDDEFINE
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform