Page 1 of 1

End dialogue when lost focus

Posted: Wed Dec 01, 2021 3:36 am
by hua

Code: Select all | Expand


     DEFINE DIALOG oDlg FROM 0,0 TO nDlgHei, nDlgWid                ;
        STYLE nOr(WS_POPUP, WS_VISIBLE) ;
        COLOR CLR_BLACK, nRgb(255,255,238) ;
        TRANSPARENT ;
        FONT oFnt PIXEL

 ACTIVATE DIALOG oDlg NOWAIT CENTERED                                  ;
        ON INIT oDlg:bLostFocus := {|| oDlg:end()}
 


I expect this code to end the dialogue box if I click anywhere outside the dialogue box but it doesn't.
Why?

TIA

Re: End dialogue when lost focus

Posted: Wed Dec 01, 2021 4:19 pm
by Natter
ACTIVATE DIALOG oDlg NOWAIT CENTERED ;
ON INIT oDlg:bNcActivate:={|lOnOff|iif(lOnOff,, oDlg:End())}

Re: End dialogue when lost focus

Posted: Wed Dec 01, 2021 7:55 pm
by cnavarro

Code: Select all | Expand


#include "Fivewin.ch"

Function Main()

   local oDlg

     DEFINE DIALOG oDlg FROM 0,0 TO 300, 600               ;
        STYLE WS_POPUP ;
        COLOR CLR_BLACK, nRgb(255,255,238) ;
        PIXEL TRUEPIXEL TRANSPARENT

     oDlg:bLostFocus := {|| oDlg:end()}
     ACTIVATE DIALOG oDlg /*NOWAIT*/ CENTERED

Return nil

 

Re: End dialogue when lost focus

Posted: Thu Dec 02, 2021 2:18 am
by hua
Thanks Natter and Cristobal.
I got the effect that I want by including oDlg:bNcActivate := {| lOnOff | iif (lOnOff ,, oDlg: End ())}

Once that's included I could remove the NOWAIT clause

Re: End dialogue when lost focus

Posted: Thu Dec 02, 2021 2:44 am
by hua
To continue, I tie the code to display the dialog box to xBrowse's right click,

Code: Select all | Expand

:aCols[4]:bRClickData := {||  ud_msginfo( cDescription) }
.

Now if I right click a row on xBrowse, the dialogue appears with the message. If I left-click anywhere outside the dialogue, it is closed. Perfect.

But if when the dialogue appears and I immediately right click on a different row, I wish the current dialogue box is closed and reshown with message of the new row, how to achieve that? Now the 2st right click opens the dialog, 2nd right click closes it, at 3rd right click only will it reopens the dialgue box

TIA