FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XBrowse online editing
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
XBrowse online editing
Posted: Tue Dec 25, 2007 04:37 PM
I reverted to the previous code.

now
1) valid values entered are assigned.
(2) values assigned thro oget:varput() in valid block are assigned and updated IF and ONLY IF the valid function does not open a new dialog, but assigns silently. for example this assignment works
if oget:varget() > 6
   oget:vaput(6)
   oget:refresh()
endif
return .t.

this assignment works and post edit updates the data.
(3) if valid function opens a dialog the value does not get assigned
Regards



G. N. Rao.

Hyderabad, India
Posts: 312
Joined: Sat Oct 08, 2005 09:12 AM
XBrowse online editing
Posted: Tue Dec 25, 2007 11:22 PM
Antonio Linares wrote:A new mallorca.exe build:
http://www.hotshare.net/file/25841-7828226dca.html

Please try to break it, thanks :-)


Antonio,

with this exe values > 6 are correctly refused.
But i can not enter valid data.

Regards,
Detlef
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
XBrowse online editing
Posted: Wed Dec 26, 2007 04:25 AM
Mr Antonio


That behavior is fine because the real assignment is done from here:

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

The VALID should not try to modify the edited value. It just jave to return .T. or .F., and a warning for the user, if needed

I may please be permitted to disagree. Valid clause can not modify the orginal value, but can modify the Get variable through VarPut. The postedit method calls the bOnPostEdit with whatever is the varget() ( in other words eval( oget:bsetget) ) at that time. So if we modify the value in valid clause, PostEdit method calls bOnPostEdit block with that assigned value.

Also it is not uncommon that Valid clauses open look up tables and help the user to select valid values.

What we need to do is to handle the Editget's lost focus block appropriately. Hope you will appreciate my point.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
XBrowse online editing
Posted: Wed Dec 26, 2007 04:47 AM
This is the latest CancelEdit method
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

Suggestion for consideration.
Why should CancelEdit method call PostEdit again? Can we not destroy the Get object here itself and refresh the browse?
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:End()
          oCol:oEditGet := nil
      endif
   next

   ::lEditMode := .f.
   ::DrawLine(.t.)
return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
XBrowse online editing
Posted: Wed Dec 26, 2007 07:51 AM

The problem with EditGetLostFocus(...) is that (oWndFromHwnd( hWndFocus ) != nil) is True even when Get is normally edited and exited with Enter Key (even with valid data). So, if (oWndFromHwnd( hWndFocus ) != nil) is Ture, we can not assume that the get object lost focus only due to navigating to other control in the same window.

Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
XBrowse online editing
Posted: Wed Dec 26, 2007 08:08 AM

Detlef,

This mallorca new build properly edits:

http://www.hotshare.net/file/25973-9932677229.html

Please try to break it, thanks! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
XBrowse online editing
Posted: Wed Dec 26, 2007 08:11 AM
This change fixes the non assignment error reported by Detlef. In METHOD Edit( nKey ) CLASS TXBrwColumn:
   ::oEditGet:bLostFocus := { | oGet, hWndFocus | EditGetLostFocus( oGet, hWndFocus, ::oBrw, ::oEditGet, Self ) }

static function EditGetLostFocus( oGet, hWndFocus, oBrw, oEditGet, oCol )

   local oWnd

   // focus goes to another control in the same application, and not to the browse
   if ( oWnd := oWndFromHwnd( hWndFocus ) ) != nil .and. ! ( oWnd == oBrw )
      oBrw:CancelEdit()               
      return nil
   endif   

   // focus goes to another application
   if GetWindowThreadProcessId( hWndFocus ) != GetWindowThreadProcessId( oBrw:hWnd )
      oBrw:CancelEdit()
      return nil
   endif   
      
   if oEditGet != nil .and. ! oEditGet:lValidating
      oCol:PostEdit()
   endif   

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
XBrowse online editing
Posted: Wed Dec 26, 2007 08:14 AM

Nageswararao,

>
The problem with EditGetLostFocus(...) is that (oWndFromHwnd( hWndFocus ) != nil) is True even when Get is normally edited and exited with Enter Key (even with valid data). So, if (oWndFromHwnd( hWndFocus ) != nil) is Ture, we can not assume that the get object lost focus only due to navigating to other control in the same window.
>

This is fixed in the previous posted source code change, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
XBrowse online editing
Posted: Wed Dec 26, 2007 08:18 AM

Nageswararao,

Please test again your mallorca changes with the new posted code, thanks. I guess the assignment from the VALID will work this time

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
XBrowse online editing
Posted: Wed Dec 26, 2007 08:23 AM

Nageswararao,

> Why should CancelEdit method call PostEdit again ?

First we need to decide if a PostEdit() should be called if a CancelEdit() is issued:

If we agree that a PostEdit() means "to do after an edit process, even if it is cancelled" then it is ok.

If we agree that PostEdit() should be called only if the edit process has not been canceled, then it should not be called from the CancelEdit().

Finally, the CancelEdit() is only calling PostEdit() once. Unless I am missing something :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
XBrowse online editing
Posted: Wed Dec 26, 2007 09:10 AM

Valid values are getting assigned. .. ok

Clicking on other cells, or other controls or other applications exits the get and restores original values. .. ok

if we click on a button on the buttonbar, the edit is cancelled and browse line is refrehsed with original values, but the button action is not executed. .. not ok

if a value is assinged in the valid block, without opening any other dialog, the new value is assigned. .. ok

But if a valid block opens a new dialog any assignment is ignored and original value is restored. .. not ok

I think while oGet:lvalidating is true, if the focus goes to any other control or application, the edit should not be cancelled.

Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
XBrowse online editing
Posted: Wed Dec 26, 2007 09:41 AM
>
if we click on a button on the buttonbar, the edit is cancelled and browse line is refrehsed with original values, but the button action is not executed. .. not ok
>

Fixed. In function EditGetLostFocus():
   if ( oWnd := oWndFromHwnd( hWndFocus ) ) != nil .and. ! ( oWnd == oBrw )
      oBrw:CancelEdit()
      SetFocus( hWndFocus )      // New !!!          
      return nil
   endif


A new mallorca.exe build:
http://www.hotshare.net/file/25986-539597049a.html
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
XBrowse online editing
Posted: Wed Dec 26, 2007 10:55 AM

Yes. Other control actions are triggered now.

Still the issue of the behavior when Valid Block opens any new dialog remains.

While we continue tests with normal edit gets, we may now need to look into issues of other Edittypes, Listbox, useredit, get + listbox etc.

May I modify the mallorca.prg to add a third column with 'AA'.'BB'.'CC' etc and edit it with a listbox?

Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
XBrowse online editing
Posted: Wed Dec 26, 2007 10:57 AM

Nageswararao,

>
Still the issue of the behavior when Valid Block opens any new dialog remains.
>

We are working on that issue

>
While we continue tests with normal edit gets, we may now need to look into issues of other Edittypes, Listbox, useredit, get + listbox etc.

May I modify the mallorca.prg to add a third column with 'AA'.'BB'.'CC' etc and edit it with a listbox?
>

Yes, please. Thanks! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
XBrowse online editing
Posted: Wed Dec 26, 2007 11:08 AM
Mr Antonio

Can you kindly make these modifications in your copy of the program?
   FOR i:=1 TO 6
      AAdd(aLin,{i,'Descripción '+Str(i), replicate( chr(64+i), 2 )})
   NEXT


in the column definitions

   oBrw:aCols[3]:cHeader      := 'Cd'
   oBrw:aCols[3]:bClrEdit     := oBrw:bClrStd
   oBrw:aCols[3]:bOnPostEdit  := { | oCol, xVal, nKey | aLin[ oBrw:nArrayAt,3] := xVal }
   oBrw:aCols[3]:nEditType    := EDIT_LISTBOX
	oBrw:aCols[3]:aEditListBound:= ;
	oBrw:aCols[3]:aEditListTxt	:= { 'AA', 'BB', 'CC', 'DD', 'EE', 'FF', 'GG', 'HH' }


Now how should a user abort the edit and retain the original values, after naviging through the list box with arrow keys?
Regards



G. N. Rao.

Hyderabad, India