Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BUG: SelStart not work in Column.Editbox when Sparse=.F.
Message
De
23/02/2006 11:57:33
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01098093
Message ID:
01098565
Vues:
16
>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?

his is an class black box version of your way (It is not bad)
o=NewObject("form1")

o.Show(1)

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='Press right mouse button to set 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
	HIDDEN SelStartWanted
	SelStartWanted = NULL
	
	Procedure RightClick
		This.SelStart = 3

	HIDDEN Procedure Value_Access
		DO CASE
			CASE m.This.SelStartWanted > 0
				This.SelStartWanted =  - m.This.SelStartWanted
			CASE m.This.SelStartWanted < 0
				This.SelStart_Assign(- m.This.SelStartWanted,.T.)
		ENDCASE
		Return m.This.Value
	
	HIDDEN PROCEDURE SelStart_Assign(SelStart,lInternal)
		IF m.lInternal
			This.SelStartWanted = NULL
			this.SelStart=m.SelStart
			RETURN
		ENDIF
		STORE m.SelStart TO This.SelStartWanted,This.SelStart
ENDDEFINE
this is my solution ( I don't put it in production !)
o=NewObject("form1")

o.Show(1)

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='Press right mouse button to set 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
	
	Procedure RightClick
		This.SelStart = 3

	HIDDEN PROCEDURE SelStart_Assign(SelStart)
		PRIVATE i
		FOR i=m.this.SelStart TO m.SelStart-1
			Editbox::keypress(4,0)
		NEXT
		FOR i=m.this.SelStart TO m.SelStart+1 STEP -1
			Editbox::keypress(19,0)
		NEXT
ENDDEFINE
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform