XBrowse online editing

Postby nageswaragunupudi » Tue Dec 25, 2007 4: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
Code: Select all  Expand view  RUN
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
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Detlef Hoefner » 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
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby nageswaragunupudi » Wed Dec 26, 2007 4: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
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby nageswaragunupudi » Wed Dec 26, 2007 4:47 am

This is the latest CancelEdit method
Code: Select all  Expand view  RUN
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?
Code: Select all  Expand view  RUN
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
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby nageswaragunupudi » Wed Dec 26, 2007 7: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
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Antonio Linares » Wed Dec 26, 2007 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Wed Dec 26, 2007 8:11 am

This change fixes the non assignment error reported by Detlef. In METHOD Edit( nKey ) CLASS TXBrwColumn:
Code: Select all  Expand view  RUN
   ::oEditGet:bLostFocus := { | oGet, hWndFocus | EditGetLostFocus( oGet, hWndFocus, ::oBrw, ::oEditGet, Self ) }

Code: Select all  Expand view  RUN
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Wed Dec 26, 2007 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Wed Dec 26, 2007 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Wed Dec 26, 2007 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby nageswaragunupudi » Wed Dec 26, 2007 9: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
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Antonio Linares » Wed Dec 26, 2007 9: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():
Code: Select all  Expand view  RUN
   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
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby nageswaragunupudi » Wed Dec 26, 2007 11:08 am

Mr Antonio

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


in the column definitions

Code: Select all  Expand view  RUN
   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
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: wilsongamboa and 61 guests