Bug in oDlg:bGotFocus

Post Reply
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Bug in oDlg:bGotFocus

Post 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

#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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Ok, but this is not consistent with the behavior of bLostFocus. Why?

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Enrico,

Do you mean with oDlg:bLostFocus ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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

   METHOD GotFocus() INLINE ::lFocused := .t.,;
                            If( ::bGotFocus != nil, Eval( ::bGotFocus ), nil )
...
   METHOD LostFocus() INLINE ::lFocused := .f.,;
                             If( ::bLostFocus != nil, Eval( ::bLostFocus ), nil )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply