GET and bLostFocus

GET and bLostFocus

Postby Maurizio » Wed Jul 12, 2023 1: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: Select all  Expand view
#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

//----------------------------------------------------------------------------//
User avatar
Maurizio
 
Posts: 796
Joined: Mon Oct 10, 2005 1:29 pm

Re: GET and bLostFocus

Postby Marc Venken » Wed Jul 12, 2023 1:28 pm

Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: GET and bLostFocus

Postby Marc Venken » Wed Jul 12, 2023 1: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 :=<|o| end rest is not needed.
....
Last edited by Marc Venken on Wed Jul 12, 2023 2:02 pm, edited 1 time in total.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: GET and bLostFocus

Postby Maurizio » Wed Jul 12, 2023 1:59 pm

Thanks Marc
but it does not work :(
Maurizo
User avatar
Maurizio
 
Posts: 796
Joined: Mon Oct 10, 2005 1:29 pm

Re: GET and bLostFocus

Postby Marc Venken » Wed Jul 12, 2023 2:03 pm

Code: Select all  Expand view

#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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: GET and bLostFocus

Postby Marc Venken » Wed Jul 12, 2023 2:05 pm

indeed. Not working what you ask. Sorry
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: GET and bLostFocus

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

Re: GET and bLostFocus

Postby Maurizio » Thu Jul 13, 2023 3: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?
User avatar
Maurizio
 
Posts: 796
Joined: Mon Oct 10, 2005 1:29 pm

Re: GET and bLostFocus

Postby karinha » Thu Jul 13, 2023 4: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: Select all  Expand view

#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
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: GET and bLostFocus

Postby Marc Venken » Thu Jul 13, 2023 8: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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: GET and bLostFocus

Postby Maurizio » Fri Jul 14, 2023 4: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
User avatar
Maurizio
 
Posts: 796
Joined: Mon Oct 10, 2005 1:29 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 104 guests