Page 1 of 1

Bug in oDlg:bGotFocus

PostPosted: Fri Dec 16, 2005 5:29 pm
by Enrico Maria Giordano
Running the following sample you can hear a beep only when the dialog is closed but not when it gets the focus:

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


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVar := SPACE( 30 )

    DEFINE DIALOG oDlg

    oDlg:bGotFocus = { || Tone( 440, 1 ) }

    @ 1, 1 GET cVar

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


EMG

PostPosted: Fri Dec 16, 2005 5:56 pm
by Antonio Linares
Enrico,

It does not look as a bug, as the dialog never gets the focus, just momentary when it is going to be closed. All the time a control has the focus.

PostPosted: Fri Dec 16, 2005 7:03 pm
by Enrico Maria Giordano
Ok, but this is not consistent with the behavior of bLostFocus. Why?

EMG

PostPosted: Sat Dec 17, 2005 6:04 am
by Antonio Linares
Enrico,

Do you mean with oDlg:bLostFocus ?

PostPosted: Sat Dec 17, 2005 9:00 am
by Enrico Maria Giordano
Yes. oDlg:bLostFocus is evaluated when a dialog losts the focus even if there are controls on it while oDlg:bGotFocus isn't.

EMG

PostPosted: Sat Dec 17, 2005 9:07 am
by Antonio Linares
Enrico,

I have been reviewing the way the Windows msgs are routed by FWH internals, and we don't make any distinction from GotFocus and LostFocus(), so it seems its a Windows behavior for dialogboxes, as Class TDialog code just does this:

Code: Select all  Expand view
   METHOD GotFocus() INLINE ::lFocused := .t.,;
                            If( ::bGotFocus != nil, Eval( ::bGotFocus ), nil )
...
   METHOD LostFocus() INLINE ::lFocused := .f.,;
                             If( ::bLostFocus != nil, Eval( ::bLostFocus ), nil )

PostPosted: Sat Dec 17, 2005 9:10 am
by Enrico Maria Giordano
Ok, no problems. Thank you.

EMG

Re: Bug in oDlg:bGotFocus

PostPosted: Fri Apr 26, 2013 8:05 pm
by Antonio Mart.