Valid, oJump and close

Valid, oJump and close

Postby Enrico Maria Giordano » Fri Sep 30, 2016 9:17 pm

Dear friends, In the following sample try to click on Close button: the focus will go on the third GET. Instead, I need the button to close the dialog. Only on pressing Enter the focus should go to the third GET. How to get this? Any ideas?

Code: Select all  Expand view  RUN
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL oGet1, oGet3

    LOCAL nVar1 := 0
    LOCAL nVar2 := 0
    LOCAL nVar3 := 0

    DEFINE DIALOG oDlg;
           SIZE 800, 600

    @ 1, 1 GET oGet1 VAR nVar1;
           SIZE 100, 13;
           VALID ( IF( nVar1 = 0, oGet1:oJump := oGet3, ), .T. )

    @ 3, 1 GET nVar2;
           SIZE 100, 13

    @ 5, 1 GET oGet3 VAR nVar3;
           SIZE 100, 13

    @ 7, 1 BUTTON "Close";
           ACTION oDlg:End()

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Valid, oJump and close

Postby dtussman » Fri Sep 30, 2016 10:29 pm

I think this might work.

Give the button a name, such as oBut1.

Then include the following line

oBut1:blclicked:= {||odlg:END()}
dtussman
 
Posts: 99
Joined: Sat Jun 06, 2015 6:57 pm

Re: Valid, oJump and close

Postby Gale FORd » Fri Sep 30, 2016 10:33 pm

You can add the Cancel clause to the Button but then the valid will not execute.
Code: Select all  Expand view  RUN

   @ 7, 1 BUTTON "Close";
           ACTION oDlg:End() CANCEL
 
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: Valid, oJump and close

Postby Enrico Maria Giordano » Sat Oct 01, 2016 8:19 am

Thank you, but the valid is disable with both suggestions. :-(

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Valid, oJump and close

Postby Enrico Maria Giordano » Sat Oct 01, 2016 8:25 am

Found!

Code: Select all  Expand view  RUN
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL oGet2, oGet4, oBtn1

    LOCAL nVar1 := 0
    LOCAL nVar2 := 0
    LOCAL nVar3 := 0
    LOCAL nVar4 := 0

    DEFINE DIALOG oDlg;
           SIZE 800, 600

    @ 1, 1 GET nVar1;
           SIZE 100, 13;
           VALID !EMPTY( nVar1 )

    @ 3, 1 GET oGet2 VAR nVar2;
           SIZE 100, 13;
           VALID ( IF( nVar2 = 0 .AND. !oBtn1:lFocused, oGet2:oJump := oGet4, ), .T. )

    @ 5, 1 GET nVar3;
           SIZE 100, 13

    @ 7, 1 GET oGet4 VAR nVar4;
           SIZE 100, 13

    @ 9, 1 BUTTON oBtn1 PROMPT "Close";
           ACTION oDlg:End()

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Valid, oJump and close

Postby Rick Lipkin » Sat Oct 01, 2016 1:52 pm

Enrico

Add this line after your close button .. it will keep any valids from firing .. hope that is the solution you are looking for ..

Rick Lipkin
Code: Select all  Expand view  RUN

oBtn2:lCancel := .t.
 
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Valid, oJump and close

Postby Enrico Maria Giordano » Sat Oct 01, 2016 1:59 pm

Thank you. No, it's not the solution I needed. I already found the proper one. Please look at the sample in my previous message.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Valid, oJump and close

Postby dtussman » Sat Oct 01, 2016 6:59 pm

Clever. That effectively disables the valid clause from the one get without disabling all the others. Wish I had known that years ago
dtussman
 
Posts: 99
Joined: Sat Jun 06, 2015 6:57 pm

Re: Valid, oJump and close

Postby Enrico Maria Giordano » Sat Oct 01, 2016 7:54 pm

In fact is better than that. You can control what to disable and what to enable using oBtn:lFocused as flag.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 104 guests