Bug in TControl

Bug in TControl

Postby Enrico Maria Giordano » Thu Mar 02, 2006 10:29 pm

The ESC key is disabled in the following sample (but it is not the only one) in the March build:

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


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL oGet, cVar := SPACE( 30 )

    DEFINE DIALOG oDlg

    @ 1, 1 GET oGet VAR cVar MEMO

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

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


It seems that the cause is a change in TControl:

Code: Select all  Expand view  RUN
METHOD KeyDown( nKey, nFlags ) CLASS TControl

   if nKey == VK_ESCAPE
      ::oWnd:KeyDown( nKey, nFlags )
      return 0
   endif


This is the previous working version:

Code: Select all  Expand view  RUN
METHOD KeyDown( nKey, nFlags ) CLASS TControl

   if nKey == VK_ESCAPE
      ::oWnd:KeyChar( nKey, nFlags )
      return 0
   endif


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

Postby Antonio Linares » Fri Mar 03, 2006 12:14 am

Enrico,

This fix looks as the right one in Class TMultiGet:
Code: Select all  Expand view  RUN
   if nKey == VK_ESCAPE  // Windows API already sends it to dialogs!!!
      if ::oWnd:ChildLevel( TDialog() ) != 0 .and. ::oWnd:lModal
         return Super:KeyChar( nKey, nFlags ) // nil
      endif
      ...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Enrico Maria Giordano » Fri Mar 03, 2006 8:33 am

It's not enough:

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


FUNCTION MAIN()

    LOCAL oDlg, oBrw

    DEFINE DIALOG oDlg

    @ 1, 1 LISTBOX oBrw FIELDS SIZE 100, 30

    oBrw:bKeyChar = { || Tone( 440, 1 ) }

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

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


What was the reason why you changed bKeyChar to bKeyDown in TControl:KeyDown() method?

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

Postby Antonio Linares » Fri Mar 03, 2006 9:08 am

Enrico,

Because it had some wrong side effects
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Fri Mar 03, 2006 9:15 am

Enrico,

In dialog.prg copy Method KeyChar() to Method KeyDown() and it gets fixed.

Anyhow, we are curious to know why the ESC comes now by KeyDown() instead of KeyChar().
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Enrico Maria Giordano » Fri Mar 03, 2006 9:21 am

Please, can you show the exact fix?

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

Postby Antonio Linares » Fri Mar 03, 2006 9:23 am

Enrico,
Code: Select all  Expand view  RUN
METHOD KeyDown( nKey, nFlags ) CLASS TDialog

   if nKey == VK_ESCAPE
      if ::oWnd == nil
         ::End()
      else
         if ::oWnd:ChildLevel( TMdiChild() ) != 0
            ::End()
         else
            if ::oWnd:ChildLevel( TDialog() ) != 0
               ::End()
            #ifdef __HARBOUR__
            elseif Upper( ::oWnd:ClassName() ) == "TMDIFRAME" // To avoid ESC being ignored
               ::End()
            #endif
            else
               return Super:KeyDown( nKey, nFlags )
            endif
         endif
      endif
   else
      return Super:KeyDown( nKey, nFlags )
   endif

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Enrico Maria Giordano » Fri Mar 03, 2006 9:42 am

It seems to work, thank you. Do I have to leave KeyChar() method in place or do I have to remove it?

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

Postby Enrico Maria Giordano » Fri Mar 03, 2006 9:57 am

Antonio Linares wrote:Enrico,

This fix looks as the right one in Class TMultiGet:
Code: Select all  Expand view  RUN
   if nKey == VK_ESCAPE  // Windows API already sends it to dialogs!!!
      if ::oWnd:ChildLevel( TDialog() ) != 0 .and. ::oWnd:lModal
         return Super:KeyChar( nKey, nFlags ) // nil
      endif
      ...


This is no more needed.

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

Postby Antonio Linares » Fri Mar 03, 2006 2:05 pm

Enrico,

Thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 47 guests