Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BUG: SelStart not work in Column.Editbox when Sparse=.F.
Message
 
À
23/02/2006 02:59:41
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01098093
Message ID:
01098446
Vues:
15
I don't have a good solution. Anyhow, the following workaround satisfies the immediate need of my current project:
Push Key Clear
o=NewObject("form1")
o.Show(1)
Pop Key

Define Class form1 As Form
	Width=500
	Height=300
	Add Object Grid1 As MyGrid
	Add Object Label1 As Label With AutoSize=.T.,Top=230;
		, Caption='Push F5 to set _Screen.ActiveForm.Grid1.Column1.Editbox1.SelStart=3'

	Procedure Load
	Create Cursor Test (f1 m)
	Insert Into Test Values ('Text Line 1')
	Insert Into Test Values ('Text Line 2')
	Go Top

EndDefine

Define Class MyGrid As Grid
	Height = 200
	RowHeight = 60
	Add Object Column1 As EditColumn
EndDefine

Define Class EditColumn As Column
	Sparse=.F.
	Add Object Header1 As Header
	Add Object Editbox1 As Editbox1
EndDefine

Define Class Editbox1 As EditBox
	SelStartWanted=-1
	SetSel=-1

	Procedure KeyPress
	Lparameters nKeyCode, nShiftAltCtrl
	If m.nKeyCode=-4	&& Key F5
		This.SelStartWanted=3
		This.SelStart=This.SelStartWanted
	EndIf

	Procedure Value_Access
	If This.SelStartWanted>=0
		*- Value_Access will run twice. Don't set SelStart in 1st time
		If This.SetSel=-1
			This.SetSel=0
		Else
			*- Set SelStart in 2nd Value_Access
			This.SelStart=This.SelStartWanted
			Store -1 To This.SelStartWanted,This.SetSel
		EndIf
	EndIf
	Return This.Value
EndDefine
This is not a good workaround because:
1) It assumes Value_Access will run twice after a key is pressed. This may not be always true.
2) I don't know if there will be any other scenarios in which some other evil events (which change SelStart again) are fired after Value_Access.
3) Although it solves the immediate problem of my current project, it doesn't work in a form of another project. I have no time find the difference between the 2 forms (one works and the other doesn't)

Fabio, could you please post your workaround?


Ben


>>Fabio,
>>
>>Thanks for you analysis, which helps me a lot in working out a workaround.
>>
>>Ben
>>
>Ben, it is not simple to find a workaround
>( the only one that I am able to find to today is with a keypress loop )
>if you found one best, post it
>thanks
>
>Fabio
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform