Page 1 of 5
XBrowse online editing
Posted: Mon Dec 24, 2007 9:04 am
by Antonio Linares
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,) }
Posted: Mon Dec 24, 2007 9:07 am
by Antonio Linares
In static function EditGetkeyDown():
change final:
return 0
into:
return nil
Posted: Mon Dec 24, 2007 9:30 am
by Antonio Linares
In METHOD Edit( nKey ) CLASS TXBrwColumn, change:
Code: Select all
if ::bEditValid != nil
::oEditGet:bValid := ::bEditValid
endif
into this:
Code: Select all
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
::oEditGet:bLostFocus := { || ::PostEdit() }
into this:
Code: Select all
::oEditGet:bLostFocus := { || If( ! ::oEditGet:lValidating, ::PostEdit(),) }
Posted: Mon Dec 24, 2007 9:42 am
by Antonio Linares
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
if ::bEditValid != nil
::oEditGet:bValid := { | oGet, lRet | ::oEditGet:lValidating := .T., lRet := Eval( ::bEditValid, oGet ), ::oEditGet:lValidating := .F., If( ! lRet, ::oEditGet:SetFocus(),), lRet }
endif
Posted: Mon Dec 24, 2007 10:00 am
by Antonio Linares
In method Edit() this is a better fix:
Code: Select all
::oEditGet:bLostFocus := { || If( ::oEditGet != nil .and. ! ::oEditGet:lValidating, ::PostEdit(),) }
Posted: Mon Dec 24, 2007 10:29 am
by Antonio Linares
Proper fix for Method CancelEdit():
Code: Select all
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
Posted: Mon Dec 24, 2007 10:43 am
by Antonio Linares
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
if ::oEditGet != nil .or. ::oEditLbx != nil .or. ::oBrw:nLen == 0
return nil
endif
into this:
Code: Select all
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
Posted: Mon Dec 24, 2007 10:52 am
by Antonio Linares
Avoiding the VALID if escape is pressed:
Code: Select all
static function EditGetkeyDown( Self, nKey )
...
case nKey == VK_ESCAPE
lExit := .t.
::oEditGet:bValid = nil
...
Posted: Mon Dec 24, 2007 11:05 am
by Antonio Linares
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.
Posted: Mon Dec 24, 2007 12:35 pm
by nageswaragunupudi
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.
Posted: Mon Dec 24, 2007 12:47 pm
by Antonio Linares
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
# 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
Posted: Mon Dec 24, 2007 1:36 pm
by nageswaragunupudi
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.
Posted: Mon Dec 24, 2007 1:46 pm
by Antonio Linares
Nageswararao,
In mallorca.prg the VALID MsgInfo() is shown only once.
How to do to show it twice ?
Posted: Mon Dec 24, 2007 1:47 pm
by nageswaragunupudi
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
Posted: Mon Dec 24, 2007 1:52 pm
by nageswaragunupudi
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.