Page 1 of 1

Exiting when click out of a dialog

Posted: Wed Nov 16, 2005 11:43 am
by Maurilio Viana
When I click in a button I activate a dialog with NoWait clause. Is possible close this dialog if I click out of his area?
For example:

Dialog1 call Dialog2 (dialog2 is nowait), if I click in Dialog1 ou other screen area I want to close Dialog2.

Regards,
Maurilio

Re: Exiting when click out of a dialog

Posted: Wed Nov 16, 2005 1:54 pm
by Enrico Maria Giordano
This is a working sample:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg

    @ 1, 1 BUTTON "Dialog2" ACTION DIALOG2( oDlg )

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


STATIC FUNCTION DIALOG2( oMainDlg )

    LOCAL oDlg

    LOCAL oGet, cVar := SPACE( 30 )
    LOCAL oBut

    DEFINE DIALOG oDlg

    oDlg:bLostFocus = { || oBut:Click() }

    @ 1, 1 GET oGet VAR cVar OF oDlg

    @ 3, 1 BUTTON oBut PROMPT "&Close" ACTION oDlg:End()

    ACTIVATE DIALOG oDlg;
             CENTER NOMODAL

    RETURN NIL
EMG

Re: Exiting when click out of a dialog

Posted: Thu Nov 17, 2005 12:16 pm
by Maurilio Viana
Thanks a lot, Enrico!

Regards,
Maurilio