XBrowse online editing

XBrowse online editing

Postby Antonio Linares » Mon Dec 24, 2007 9:04 am

Detlef,

We are intensively testing fwh\samples\mallorca.prg to fix it.

We have already located and fixed some issues:

1. Class TXBrowse Method CancelEdit(). This line should be removed:

// oCol:oEditGet:nLastKey := VK_RETURN

2. In mallorca.prg change this lines:

oBrw:aCols[1]:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_RETURN, aLin[ oBrw:nArrayAt,1] := xVal,) }

oBrw:aCols[2]:bOnPostEdit := { | oCol, xVal, nKey | If( nKey == VK_RETURN, aLin[ oBrw:nArrayAt,2] := xVal,) }
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Mon Dec 24, 2007 9:07 am

In static function EditGetkeyDown():

change final:

return 0

into:

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Mon Dec 24, 2007 9:30 am

In METHOD Edit( nKey ) CLASS TXBrwColumn, change:
Code: Select all  Expand view
   if ::bEditValid != nil
      ::oEditGet:bValid := ::bEditValid
   endif

into this:
Code: Select all  Expand view
   if ::bEditValid != nil
      ::oEditGet:bValid := { | oGet, lRet | ::oEditGet:lValidating := .T., lRet := Eval( ::bEditValid, oGet ), ::oEditGet:lValidating := .F., lRet }
   endif

In the same method change:
Code: Select all  Expand view
   ::oEditGet:bLostFocus := { || ::PostEdit() }

into this:
Code: Select all  Expand view
   ::oEditGet:bLostFocus := { || If( ! ::oEditGet:lValidating, ::PostEdit(),) }
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Mon Dec 24, 2007 9:42 am

In In METHOD Edit( nKey ) CLASS TXBrwColumn, this is a better fix as it returns the focus to the GET if the VALID return .F.:
Code: Select all  Expand view
   if ::bEditValid != nil
      ::oEditGet:bValid := { | oGet, lRet | ::oEditGet:lValidating := .T., lRet := Eval( ::bEditValid, oGet ), ::oEditGet:lValidating := .F., If( ! lRet, ::oEditGet:SetFocus(),), lRet }
   endif
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Mon Dec 24, 2007 10:00 am

In method Edit() this is a better fix:
Code: Select all  Expand view
   ::oEditGet:bLostFocus := { || If( ::oEditGet != nil .and. ! ::oEditGet:lValidating, ::PostEdit(),) }
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Mon Dec 24, 2007 10:29 am

Proper fix for Method CancelEdit():
Code: Select all  Expand view
METHOD CancelEdit() CLASS TXBrowse

   local oCol, nFor, nlen

   if ! ::lEditMode
      return nil
   endif

   nLen := Len( ::aCols )

   for nFor := 1 to nLen
      oCol := ::aCols[ nFor ]
      if oCol:oEditGet != nil
         oCol:oEditGet:VarPut( Eval( oCol:bEditValue ) )
         oCol:oEditGet:bValid = nil
         oCol:PostEdit()
      endif
   next

   ::lEditMode := .f.

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Mon Dec 24, 2007 10:43 am

This fix is required in Class TXBrwColumn Method PaintData(), so if a VALID is .F. then the column is properly painted. Change this:
Code: Select all  Expand view
   if ::oEditGet != nil .or. ::oEditLbx != nil .or. ::oBrw:nLen == 0
      return nil
   endif

into this:
Code: Select all  Expand view
   if ( ::oEditGet != nil .and. nRow == ::oBrw:nRowSel ) .or. ::oEditLbx != nil .or. ::oBrw:nLen == 0
      return nil
   endif

We are getting close to have samples\mallorca.prg working fine :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Mon Dec 24, 2007 10:52 am

Avoiding the VALID if escape is pressed:
Code: Select all  Expand view
static function EditGetkeyDown( Self, nKey )
...
      case nKey == VK_ESCAPE
           lExit := .t.
           ::oEditGet:bValid = nil
...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Mon Dec 24, 2007 11:05 am

Here you have the new mallorca.exe:
http://www.hotshare.net/file/25599-33319869aa.html

Please test it and see if you can break it, thanks

There is a pending painting issue when returning from the VALID (a painted frame around the GET). We are working to solve it.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby nageswaragunupudi » Mon Dec 24, 2007 12:35 pm

Thanks Mr Antonio. Extremely happy that we are now getting reliable inline edit for our favourite xBrowse.

I have been working on this issue, but now that you have done the most part of it I shall adopt your changes now.

Are these the only changes to the source code ? I adopt them and make extensive tests.

My first test with mallorca.exe is working well.
Regards

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

Postby Antonio Linares » Mon Dec 24, 2007 12:47 pm

Nageswararao,

>
Are these the only changes to the source code ? I adopt them and make extensive tests.
>

Yes, the ones that I have published here.

> My first test with mallorca.exe is working well.

This is samples\mallorca.prg with some little changes:
Code: Select all  Expand view
# INCLUDE "FiveWin.ch"
# INCLUDE "XBrowse.ch"
//-------------
FUNCTION Main()
//-------------
   LOCAL oWnd,aLin:={},i,oBrw
   FOR i:=1 TO 6
      AAdd(aLin,{i,'Descripción '+Str(i)})
   NEXT
   DEFINE WINDOW oWnd
   //--Definición Objeto TxBrowse
   oBrw:=TxBrowse():New(oWnd)
   oBrw:SetArray(aLin)
   oBrw:nColDividerStyle := LINESTYLE_BLACK
   oBrw:nRowDividerStyle := LINESTYLE_BLACK
   oBrw:nMarqueeStyle    := MARQSTYLE_HIGHLCELL

   oBrw:aCols[1]:cHeader      := 'Cod'
   oBrw:aCols[1]:cEditPicture := '@k 99'
   oBrw:aCols[1]:bClrEdit     := oBrw:bClrStd
   oBrw:aCols[1]:bOnPostEdit  := { | oCol, xVal, nKey | If( nKey == VK_RETURN, aLin[ oBrw:nArrayAt,1] := xVal,) }
   oBrw:aCols[1]:nEditType    := EDIT_GET
   oBrw:aCols[1]:bEditValid   := { | oGet | Valida( oGet ) } //<========
   //--
   oBrw:aCols[2]:cHeader      := 'Descripción'
   oBrw:aCols[2]:bClrEdit     := oBrw:bClrStd
   oBrw:aCols[2]:bOnPostEdit  := { | oCol, xVal, nKey | If( nKey == VK_RETURN, aLin[ oBrw:nArrayAt,2] := xVal,) }
   oBrw:aCols[2]:nEditType    := EDIT_GET
   //--
   oBrw:CreateFromCode()
   oBrw:bRClicked = { | nRow, nCol | ShowPopup( nRow, nCol, oBrw, aLin ) }
   oWnd:oClient:=oBrw
   
   ACTIVATE WINDOW oWnd
   
RETURN NIL

STATIC FUNCTION Valida( oGet )
   
    IF oGet:Value() > 6
       MsgAlert( "Must be lower than 7" )
       return .F.
    ENDIF
   
RETURN .T.

function ShowPopup( nRow, nCol, oBrw, aLin )

   local oMenu
   
   MENU oMenu POPUP
      MENUITEM "Add" ACTION ( AAdd( aLin, { AllTrim( Str( Len( aLin ) + 1 ) ), "New item" } ), oBrw:SetArray( aLin ), oBrw:Refresh() )
      MENUITEM "Del" ACTION ( ADel( aLin, oBrw:nArrayAt ), ASize( aLin, Len( aLin ) - 1 ), oBrw:SetArray( aLin ), oBrw:Refresh() )
      MENUITEM "Select" ACTION ( oBrw:GoTop(), oBrw:nArrayAt := 3, oBrw:Refresh() )
   ENDMENU
   
   ACTIVATE POPUP oMenu WINDOW oBrw AT nRow, nCol
   
return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby nageswaragunupudi » Mon Dec 24, 2007 1:36 pm

Mr Antonio

Great. Almost all the problems I faced earlier seem to have been addressed. I shall continue my tests on other data also.

At this point only one observation that the EditValid block is getting evaluated twice. Can this be avoided?

After solving the inline edit issue, you have to address the listbox issue also. Once the user presses on the arrow, the listbox is shown. After the user moves around the listbox, he has no way to cancel ( esc does not help) and retain the original value unchanged.

We shall be glad if you keep publishing whatever changes you keep making with regards to edits.
Regards

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

Postby Antonio Linares » Mon Dec 24, 2007 1:46 pm

Nageswararao,

In mallorca.prg the VALID MsgInfo() is shown only once.

How to do to show it twice ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42069
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby nageswaragunupudi » Mon Dec 24, 2007 1:47 pm

Problem:

Enter an invalid value in the first column. Say enter 9 and press Enter key. As expected the valid msg is shown twice and the focus remains on the get.

Without doing anything click on any other program window. Then the invalid value is written and cursor moves to next column
Regards

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

Postby nageswaragunupudi » Mon Dec 24, 2007 1:52 pm

I made the changes you published. For the sake of clarity I made the changes in a derived class. With that I compiled your mallorca program ( latest version).

There seems to be slight difference in behavior between your exe and what i compiled here. I may need to check if i made all the corrections properly.
Regards

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 76 guests