FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour GET and bLostFocus
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
GET and bLostFocus
Posted: Wed Jul 12, 2023 01:20 PM
Hello,
I have a problem with GET dialog and XBROWSE (as example)

When I leave the field First , I'd like the data in the browse udated .
This works if I switch from First to Last
But when I switch from First to browse the update is on the wrong row because the pointer has already changed.

Regards Maurizio
www.nipeservice.com
Code (fw): Select all Collapse
#include "FiveWin.Ch"
 
REQUEST DBFCDX
//----------------------------------------------------------------------------//
function main()
   local  aData, oDlg, oBrw,  cFirst := '',cLast :='' ,oGet,oGet1 

   USE CUSTOMER NEW VIA "DBFCDX"
   aData       := FW_DbfToArray("FIRST, LAST")
   CLOSE DATA

   cFirst := aData[1,1]
   cLast  := aData[1,2]
 
   DEFINE DIALOG oDlg SIZE 800,400 PIXEL  

   @ 10,10  SAY 'Firs'   OF oDlg update PIXEL 
   @ 10,60  get oGet Var cFirst   OF oDlg update PIXEL  SIZE 100,15 

    oGet:bLostFocus :=<|o| 
            Local n :=  oBrw:nArrayAt
            Local uOldVal := oGet:cText
            aData[n,1] := uOldVal
            oBrw:RefreshCurrent()
        Return nil  
    >
        
   
   @ 10,200  SAY 'Last'   OF oDlg update PIXEL 
   @ 10,260 get oGet1 Var cLast   OF oDlg update PIXEL  SIZE 100,15
    
   @ 30,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg DATASOURCE aData AUTOCOLS ;
       HEADERS "FIRST", "LAST" CELL LINES NOBORDER

   WITH OBJECT oBrw
      :CreateFromCode()
      :bChange := <|| 
            cFirst := aData[oBrw:nArrayAt,1]
            cLast  := aData[oBrw:nArrayAt,2]
            oDlg:Update()
           Return nil 
        >
   END
 
   ACTIVATE DIALOG oDlg CENTERED
 
return nil

//----------------------------------------------------------------------------//
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: GET and bLostFocus
Posted: Wed Jul 12, 2023 01:28 PM
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: GET and bLostFocus
Posted: Wed Jul 12, 2023 01:54 PM

I tried this and seems to work

@ 10,60 get oGet Var cFirst OF oDlg update PIXEL SIZE 100,15;

 valid( (oBrw:first:varput(cFirst),.t.,oBrw:refresh()),.t.)



oGet:bLostFocus :=&lt;|o|  end rest is not needed.

....

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: GET and bLostFocus
Posted: Wed Jul 12, 2023 01:59 PM
Thanks Marc
but it does not work :(
Maurizo
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: GET and bLostFocus
Posted: Wed Jul 12, 2023 02:03 PM
Code (fw): Select all Collapse
#include "FiveWin.Ch"

REQUEST DBFCDX
//----------------------------------------------------------------------------//
function main()
   local  aData, oDlg, oBrw,  cFirst := '',cLast :='' ,oGet,oGet1

   USE CUSTOMER NEW VIA "DBFCDX"
   aData       := FW_DbfToArray("FIRST, LAST")
   CLOSE DATA

   cFirst := aData[1,1]
   cLast  := aData[1,2]

   DEFINE DIALOG oDlg SIZE 800,400 PIXEL

   @ 10,10  SAY 'Firs'   OF oDlg update PIXEL
   @ 10,60  get oGet Var cFirst   OF oDlg update PIXEL  SIZE 100,15;
     valid( (oBrw:first:varput(cFirst),.t.,oBrw:refresh()),.t.)

   @ 10,200  SAY 'Last'   OF oDlg update PIXEL
   @ 10,260 get oGet1 Var cLast   OF oDlg update PIXEL  SIZE 100,15

   @ 30,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg DATASOURCE aData AUTOCOLS ;
       HEADERS "FIRST", "LAST" CELL LINES NOBORDER

   WITH OBJECT oBrw
      :CreateFromCode()
      :bChange := <||
            cFirst := aData[oBrw:nArrayAt,1]
            cLast  := aData[oBrw:nArrayAt,2]
            oDlg:Update()
           Return nil
        >
   END

   ACTIVATE DIALOG oDlg CENTERED

return nil
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: GET and bLostFocus
Posted: Wed Jul 12, 2023 02:05 PM

indeed. Not working what you ask. Sorry

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: GET and bLostFocus
Posted: Thu Jul 13, 2023 05:24 AM

Dear Maurizio,

You example works fine here

> But when I switch from First to browse the update is on the wrong row because the pointer has already changed

Are you using an INDEX ? Here the xbrowse pointer does not change

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: GET and bLostFocus
Posted: Thu Jul 13, 2023 03:24 PM

Hello, I think I explained it wrong.

If I change the focus from the FIRST field to the LAST field, the data is changed because oBrw:nArrayAt is still correct.

On the other hand, if I change the focus by clicking on another row in xbrowse (not the one i am reading in FIRST/LAST),+

the data is not changed because I lost the correct row, oBrw:nArrayAt already has the value of the new row.

Can I find a solution to this problem?

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: GET and bLostFocus
Posted: Thu Jul 13, 2023 04:51 PM
Maurizio, lo siento, pero no veo dónde está el "error", en mi opinión, está funcionando perfectamente. ¿Qué en tu opinión no es correcto?

Maurizio, sorry, but I can't see where the "error" is, in my opinion, it's working perfectly. What in your opinion is not correct?
Code (fw): Select all Collapse
#include "FiveWin.Ch"
 
REQUEST OrdKeyNo, OrdKeyCount, OrdCreate, OrdKeyGoto
REQUEST DBFCDX, DBFFPT

FUNCTION Main()

   LOCAL aData, oDlg, oBrw,  cFirst := '', cLast :=' ' , oGet, oGet1, oFont

   USE CUSTOMER NEW EXCLUSIVE
   GO TOP

   INDEX ON Field->First TO CUSTOMER ASCEND
   // INDEX ON Field->Last  TO CUSTOMER

   CLOSE DATA

   USE CUSTOMER INDEX CUSTOMER SHARED NEW
   GO TOP

   aData  := FW_DbfToArray( "FIRST, LAST" )

   cFirst := aData[1,1]
   cLast  := aData[1,2]
 
   DEFINE FONT oFont  NAME "Ms Sans Serif"  SIZE 00, -14 BOLD

   DEFINE DIALOG oDlg SIZE 800, 400 PIXEL FONT oFont

   oDlg:lHelpIcon := .F.

   @ 10,10 SAY 'Firs' OF oDlg update PIXEL

   @ 10,60 get oGet Var cFirst OF oDlg update PIXEL  SIZE 100,15

   oGet:bLostFocus :=<|o|
      Local n :=  oBrw:nArrayAt
      Local uOldVal := oGet:cText
      aData[n,1] := uOldVal
      oBrw:RefreshCurrent()
      Return nil
   >
   
   @ 10,200  SAY 'Last' OF oDlg update PIXEL

   @ 10,260 get oGet1 Var cLast OF oDlg update PIXEL SIZE 100,15
   
   @ 30,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg DATASOURCE aData AUTOCOLS ;
       HEADERS "FIRST", "LAST" CELL LINES NOBORDER

   WITH OBJECT oBrw

      oBrw:lIncrFilter := .T.
      oBrw:lSeekWild   := .T.

      :CreateFromCode()
      :bChange := <||
      cFirst := aData[oBrw:nArrayAt,1]
      cLast  := aData[oBrw:nArrayAt,2]
      oDlg:Update()
      Return nil
      >

   END

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( oBrw:cSeek( "" ), oBrw:SetFocus(), .F. )

   CLOSE DATA

   oFont:End()
 
RETURN NIL

// FIN / END
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: GET and bLostFocus
Posted: Thu Jul 13, 2023 08:07 PM

If we enter a name in the get and not use any key, but simply point the mouse to a row on xbrowse, the input from the get is not validated or even known, so the change is doing it with the original data in the get.

Aslong we don't enter the get the the get is keeping the original data. I see the problem : the newdata in the get is not yet confirmed. so can't be saved. I do think there is a data in Get that can be used, but did not found it

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Re: GET and bLostFocus
Posted: Fri Jul 14, 2023 04:15 AM
Antonio,
it's not a problem of INDEX because in xbrowse I use array.

I think the problem is when we point the mouse to another row
of xbrowse:
1-xbrowse changes row
2-get executes lostfocus
Antonio try this:
Example 1This works
1-xbrowse on line 1
2-make a change of First
3-steps to the Last field
at the same time the value of First in row 1( in xbrowse ) is updated
Example 2 this doesn't work
1-xbrowse on row 1
2-make a change of First
3-click in xbrowse row 3
in this case line 1 is not updated

Continue the discussion