Xbrowse Edit Help

Xbrowse Edit Help

Postby Richard Chidiak » Fri Mar 07, 2008 8:47 pm

Hello

I have a problem with xbrowse Edit, look like a bug

if i use the following syntax :
oCol:bStrData := {|| ALLTRIM(TRANSFORM((FUSER)->TTC,"@Z 999 999 999.99")) } Edit can not occur if the value is 0 there is no way to type something in the column, Edit-type is 1

If i remove the alltrim, then everything works OK

I need the alltrim as i use an underline font ,

I have been searching since a while in xbrowse.prg without success, probably missed something. Any help is appreciated

Thanks

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Xbrowse Edit Help

Postby Richard Chidiak » Fri Mar 07, 2008 9:07 pm

I found where the problem comes from

Method edit(nkey)

DEFAULT ::cEditPicture := ""

uValue := Eval( ::bEditValue )

uValue in my case is a string length 0 , Edit can not happen

i have added the following

IF LEN(UVALUE) = 0 // CHIDIAK
UVALUE := REPLICATE(" ",15)
ENDIF

Now it works OK , i am sure there is another way to "fill" uvalue , maybe Antonio ?
Note ceditpicture has always been set

HTH

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Postby nageswaragunupudi » Sat Mar 08, 2008 2:18 pm

To use the edit features of xbrowse, this is the recommended way:
Code: Select all  Expand view
oCol:bEditvalue        := { || FUSER->TTC }
oCol:cEditPicture      := "@Z 999 999 999.99"
oCol:nEditType         := EDIT_GET
oCol:bStrData          := { || Transform( FUSER->TTC, "@Z 999 999 999.99" }
oCol:bPostEdit          := { | oCol, uValue, nLastKey | If( nLastKey == 13, FUSER->TTC := uValue,  nil )  }
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10481
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby nageswaragunupudi » Sat Mar 08, 2008 3:22 pm

If the above code looks complex or seems to be more time consuming to write, it is simpler to use the command
Code: Select all  Expand view
ADD TO oBrw DATA FUSER->TTC PICTURE "@Z 999 999 999.99" ;
   EDITABLE ;
   ON EDIT { | oCol, uValue, nLastKey | If( nLastKey == 13, FUSER->TTC := uValue,  nil )  }
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10481
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Richard Chidiak » Sun Mar 09, 2008 6:37 am

Thank you for your help,

i was just missing
oCol:bEditvalue := { || FUSER->TTC }

Now everything is OK

Best regards

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Postby ask » Tue Mar 11, 2008 9:37 am

nageswaragunupudi wrote:To use the edit features of xbrowse, this is the recommended way:
Code: Select all  Expand view
oCol:bEditvalue        := { || FUSER->TTC }
oCol:cEditPicture      := "@Z 999 999 999.99"
oCol:nEditType         := EDIT_GET
oCol:bStrData          := { || Transform( FUSER->TTC, "@Z 999 999 999.99" }
oCol:bPostEdit          := { | oCol, uValue, nLastKey | If( nLastKey == 13, FUSER->TTC := uValue,  nil )  }



Is there a way to call edit without double clicking the column? If you know METHOD lEditCol( nCol, uVar, cPicture, bValid, nClrFore, nClrBack, ;
cMsg, cError ) of TCBrowse .


Thanks
A.S.K
ask
 
Posts: 99
Joined: Wed Nov 02, 2005 10:40 am

Postby nageswaragunupudi » Tue Mar 11, 2008 12:16 pm

If oBrw:lFastedit := .t.
then pressing enter or any alpha or numeric key will invoke the edit and the key pressed will be the first key. This works like Excel cell edit.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10481
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby ask » Tue Mar 11, 2008 12:28 pm

nageswaragunupudi wrote:If oBrw:lFastedit := .t.
then pressing enter or any alpha or numeric key will invoke the edit and the key pressed will be the first key. This works like Excel cell edit.


Thank you for your answer but how can you invoke edit by code? leditcell do just that

regards
A.S.K
ask
 
Posts: 99
Joined: Wed Nov 02, 2005 10:40 am

Postby nageswaragunupudi » Tue Mar 11, 2008 3:51 pm

Please try oCol:Edit()

I am not doing that for this reason. In the earlier browses, we were invoiking lEdit in response to some user action. In other words, Edit happens only in response to some user action. Earlier we had to deal with the user actions ourselves and decide in our code whether or not and when to invoke the edit method.

Xbrowse takes away that responsibility from the programmer. The browse responds to the user actions once we set the Data of the column and browse objects. This simplifies our coding.

Even if we use oCol:Edit() through our code, when do we invoke the edit? We ourselves watch the key strokes in our code and the decide to invoke oCol:Edit() ( or lEdit in ealier browses). Instead, is it not more convinient for us to code our business logic only, leaving the job of watching events / keystrokes and responding appropriately to the browse object itself?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10481
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby ask » Wed Mar 12, 2008 10:43 am

nageswaragunupudi wrote:Please try oCol:Edit()

I am not doing that for this reason. In the earlier browses, we were invoiking lEdit in response to some user action. In other words, Edit happens only in response to some user action. Earlier we had to deal with the user actions ourselves and decide in our code whether or not and when to invoke the edit method.

Xbrowse takes away that responsibility from the programmer. The browse responds to the user actions once we set the Data of the column and browse objects. This simplifies our coding.

Even if we use oCol:Edit() through our code, when do we invoke the edit? We ourselves watch the key strokes in our code and the decide to invoke oCol:Edit() ( or lEdit in ealier browses). Instead, is it not more convinient for us to code our business logic only, leaving the job of watching events / keystrokes and responding appropriately to the browse object itself?



There is a BIG difference if you use oCol:Edit() with window and dialog. With dialog witch I am interested for is not working but with window works fine.

regards ,
A.S.K
ask
 
Posts: 99
Joined: Wed Nov 02, 2005 10:40 am

Postby nageswaragunupudi » Wed Mar 12, 2008 10:55 am

Though I never use oCol:Edit() directly from code, for your sake I just now tested calling oCol:Edit() of a column in TXBrowse in Dialog. It is working fine for me. I would request you to give it a try once more.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10481
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby ask » Wed Mar 12, 2008 11:08 am

nageswaragunupudi wrote:Though I never use oCol:Edit() directly from code, for your sake I just now tested calling oCol:Edit() of a column in TXBrowse in Dialog. It is working fine for me. I would request you to give it a try once more.


The bellow example is taken from testxbrw.prg I made some changes and here it is:

Code: Select all  Expand view
STATIC FUNCTION AutoEdit( oWnd )

   local oChild, oBrw, oCol
   local nFor

   DEFINE window oChild TITLE "Auto edit browse"

   oBrw := TXBrowse():New( oWnd )

   
   oBrw:nColDividerStyle    := LINESTYLE_BLACK
   oBrw:nRowDividerStyle    := LINESTYLE_BLACK
   oBrw:lColDividerComplete := .t.

   oBrw:SetRDD()


   oBrw:CreateFromCode()
   
   

      oCol := oBrw:aCols[ 1 ]
      oCol:nEditType := 1
      oCol:bOnPostEdit := {|o, v, n| iif( n != VK_ESCAPE, FieldPut( o:nCreationOrder, v ), ) }
   
   
   ACTIVATE window oChild ON INIT (oBrw:nTop():=0,oBrw:nLeft():=0,oBrw:nWidth():=oChild:nWidth(),oBrw:nHeight():=oChild:nHeight(),oBrw:nMarqueeStyle:= MARQSTYLE_HIGHLCELL,oBrw:aCols[ 1 ]:EDIT())

RETURN NIL


This is working perfectly. Try changing window to dialog and see that is not working

regards,
A.S.K
ask
 
Posts: 99
Joined: Wed Nov 02, 2005 10:40 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 29 guests