Page 1 of 1

Cancel on Valid

PostPosted: Thu Dec 08, 2011 4:22 pm
by Rick Lipkin
To All

I am trying to trap my Cancel button event during a Get - Valid scenario .. Here is the code

Code: Select all  Expand view


Static lClose := nil
..
REDEFINE GET oClname        VAR cClname        ID 120 of oREQ PICTURE "@!" ;
            valid CustGet(cClname, cMODE, oRsReq, oButt1,oButt2,oButt3,oButt4, "1") UPDATE

...
...
...

REDEFINE BTNBMP oBUTT2 ID 112 of oREQ   ;    // cancel
         RESOURCE "CANCEL1","DCANCEL1","DCANCEL1" ;
         PROMPT "&Cancel   " LEFT 2007;
         ACTION ( lClose := .t.,lOK := .F., oREQ:END() )

//----------------------------------
Static Func CUSTGET( cNAME, cMODE, oRsReq, oButt1,oButt2,oButt3,oButt4, cWhere  )

LOCAL oDLG,oLBX, oRsCust, cSQL, oERR, oCol
LOCAL oBTN1,oBTN2,oBTN3,lOK,oBrush

msginfo( lclose )

 


As you can see from the screen shot .. the valid fires before the lclose variable is initialized and I can not seem to trap the event and return(.t.) from the valid ..

Thanks
Rick Lipkin

Image

Re: Cancel on Valid

PostPosted: Thu Dec 08, 2011 7:39 pm
by Gale FORd
Try adding
oBUTT2:lCancel := .t.

Re: Cancel on Valid

PostPosted: Thu Dec 08, 2011 8:45 pm
by Rick Lipkin
Gale

How would I trap that in the Valid function if the cursor is in the Get field ??

Code: Select all  Expand view

REDEFINE BTNBMP oBUTT2 ID 112 of oREQ   ;    // cancel
         RESOURCE "CANCEL1","DCANCEL1","DCANCEL1" ;
         PROMPT "&Cancel   " LEFT 2007;
         ACTION ( lOK := .F., oBUTT2:lCancel := .t., oREQ:END() )

 


I inserted your suggestion but the valid still fires if the cursor is in the Customer last name field ??

Code: Select all  Expand view

REDEFINE GET oClname        VAR cClname        ID 120 of oREQ PICTURE "@!" ;
            valid CustGet(cClname, cMODE, oRsReq, oButt1,oButt2,oButt3,oButt4, "1") UPDATE

 


Thanks
Rick Lipkin

Re: Cancel on Valid

PostPosted: Thu Dec 08, 2011 10:20 pm
by Armando
Rick:

With the BUTTON class I do this way

Code: Select all  Expand view

    REDEFINE BUTTON oCancelar ID 902 OF oDlg UPDATE CANCEL;
        ACTION oDlg:END();
        MESSAGE "Cancela el proceso"
 


Pls note the CANCEL clause, perhaps these can help you

Regards

Re: Cancel on Valid

PostPosted: Thu Dec 08, 2011 10:23 pm
by Gale FORd
You need to do it like this:
Code: Select all  Expand view

REDEFINE BTNBMP oBUTT2 ID 112 of oREQ   ;    // cancel
         RESOURCE "CANCEL1","DCANCEL1","DCANCEL1" ;
         PROMPT "&Cancel   " LEFT 2007;
         ACTION ( lOK := .F., oREQ:END() )
oBUTT2:lCancel := .t.
 


This allows to Button to fire and ignore the valid function.

Re: Cancel on Valid

PostPosted: Thu Dec 08, 2011 10:25 pm
by Gale FORd
I don't think the Cancel clause works on btnbmp class. You have to use oButton:lCancel := .f.

Re: Cancel on Valid

PostPosted: Thu Dec 08, 2011 11:13 pm
by Rick Lipkin
Gale

YES .. your advice worked GREAT .. oButton:lCancel := .t. allowed the valid NOT to fire if the cursor was in the Valid Get !

Thanks
Rick Lipkin

Code: Select all  Expand view

REDEFINE BTNBMP oBUTT2 ID 112 of oREQ   ;    // cancel
         RESOURCE "CANCEL1","DCANCEL1","DCANCEL1" ;
         PROMPT "&Cancel   " LEFT 2007;
         ACTION ( lOK := .F., oREQ:END() )
         oButt2:lCancel := .t.