Page 1 of 1

CTRL-TAB and TFolder

Posted: Mon Jul 18, 2011 3:40 pm
by Patrizio
Hi, the control TFolder() don't change page by the pression of CTRL-TAB or CTRL-SHIFT-TAB on keyborad (standard windows).

I've tried to add a custom function to TFolder():bKeyDown but seem it doesn't work.

The code is the same of Folder.prg in \FWH\Samples with the custom function.

Code: Select all

#include "fivewin.ch"

function Main()

   local oDlg, oFld

   DEFINE DIALOG oDlg TITLE "FiveWin Dynamic folders" ;
      FROM 5, 5 TO 20, 49

   @ 0.5, 1 FOLDER oFld PROMPT "&xBase", "&And OOP", "&Power" ;
      OF oDlg SIZE 160, 90

   @ 1, 1 BUTTON "&Hello" OF oFld:aDialogs[ 1 ] ;
     ACTION MsgInfo( "Hello world!" )

   @ 5.5, 11 BUTTON "Ok" OF oDlg ACTION oDlg:End()

   oFld:bKeyDown  := {|nKey,nFlags|TestKey(oFld,nKey,nFlags)}

   ACTIVATE DIALOG oDlg CENTERED

return nil

procedure AppSys // Xbase++ requirement

return


FUNC TestKey(oFld,nKey,nFlags)
   IF nKey == VK_TAB .and. GetKeyState( VK_CONTROL )
      IF GetKeyState(VK_SHIFT)
         IF oFld:nOption == 1
            oFld:SetOption( Len(oFld:aDialogs) )
         ELSE
            oFld:SetOption( oFld:nOption - 1 )
         ENDIF
      ELSE
         IF oFld:nOption == Len(oFld:aDialogs)
            oFld:SetOption( 1 )
         ELSE
            oFld:SetOption( oFld:nOption + 1 )
         ENDIF
      ENDIF
   ENDIF
RETURN nKey

Re: CTRL-TAB and TFolder

Posted: Tue Jul 19, 2011 7:41 am
by Antonio Linares
Patrizio,

We have implemented it for FWH 11.07 modifying Class TControl Method KeyDown() this way:

Code: Select all

METHOD KeyDown( nKey, nFlags ) CLASS TControl

   local oFolder
   ...
   if ::lDrag
      ...
   else
      if nKey == VK_TAB .and. GetKeyState( VK_CONTROL )
         if ::oWnd:oWnd != nil .and. ::oWnd:oWnd:IsKindOf( "TFOLDER" )
            oFolder = ::oWnd:oWnd
            if GetKeyState( VK_SHIFT )     
               if oFolder:nOption == 1
                  oFolder:SetOption( Len( oFolder:aDialogs ) )
               else
                  oFolder:SetOption( oFolder:nOption - 1 )
               endif
            else
               if oFolder:nOption == Len( oFolder:aDialogs )
                  oFolder:SetOption( 1 )
               else
                  oFolder:SetOption( oFolder:nOption + 1 )
               endif
            endif
            return 0                 
         endif 
      else      
         return Super:KeyDown( nKey, nFlags )
      endif   
   endif
   ...
 
Many thanks for your feedback! :-)

Re: CTRL-TAB and TFolder

Posted: Tue Jul 19, 2011 11:03 am
by Patrizio
Thank you Antonio :D