Some modifications to tget/tcontrol/twindow
Posted: Tue Jun 12, 2007 10:02 am
Hi,
I've got some child dialogs that have single controls on them, in which case vk_tab does not do anything, but the class doesn't return it either.
I made these modifications:
tget.prg
control.prg
window.prg
I've got some child dialogs that have single controls on them, in which case vk_tab does not do anything, but the class doesn't return it either.
I made these modifications:
tget.prg
Code: Select all
Method KeyChar
...
case nKey == VK_TAB .and. GetKeyState( VK_SHIFT )
// AS 23/07/2007 Changes as per 2007/01 FWH
if ::bChange != nil .and. ( ::oGet:Changed .or. ( ::oGet:buffer != nil .and. ::oGet:UnTransform() != ::oGet:Original ) )
// if ::bChange != nil
lAccept = Eval( ::bChange, nKey, nFlags, Self )
if ValType( lAccept ) == "L" .and. lAccept
if Upper( ::oWnd:ClassName() ) == "TCOMBOBOX"
::oWnd:oWnd:GoPrevCtrl( ::hWnd )
else
IF !::oWnd:GoNextCtrl( ::hWnd )
return Super:KeyChar( nKey, nFlags )
endif
endif
endif
else
if Upper( ::oWnd:ClassName() ) == "TCOMBOBOX"
::oWnd:oWnd:GoPrevCtrl( ::hWnd )
else
IF !::oWnd:GoNextCtrl( ::hWnd )
return Super:KeyChar( nKey, nFlags )
endif
endif
endif
return 0
case nKey == VK_TAB .or. nKey == VK_RETURN
if ::bChange != nil .and. ( ::oGet:Changed .or. ( ::oGet:buffer != nil .and. ::oGet:UnTransform() != ::oGet:Original ) )
// if ::bChange != nil
lAccept = Eval( ::bChange, nKey, nFlags, Self )
if ValType( lAccept ) == "L" .and. lAccept
IF !::oWnd:GoNextCtrl( ::hWnd )
return Super:KeyChar( nKey, nFlags )
endif
endif
else
if !::oWnd:GoNextCtrl( ::hWnd )
return Super:KeyChar( nKey, nFlags )
endif
endif
#ifndef __CLIPPER__
if nKey == VK_RETURN // Execute DEFPUSHBUTTON Action
Super:KeyChar( nKey, nFlags )
endif
#endif
return 0
Code: Select all
Method KeyChar
.
.
.
case nKey == VK_TAB .and. GetKeyState( VK_SHIFT ) .and. ::oWnd:GoPrevCtrl( ::hWnd )
return 0 // We don't want API default behavior
case nKey == VK_TAB .and. len(::oWnd:aControls) > 1 .and. ::oWnd:GoNextCtrl( ::hWnd )
return 0 // We don't want API default behavior
Code: Select all
METHOD KeyDown( nKey, nFlags ) CLASS TWindow
local bKeyAction := SetKey( nKey )
local nRetval := 0
// AS 12/06/2007 Only process tab if there are controls to do it for
// if nKey == VK_TAB .and. ::oWnd != nil .and. GetKeyState( VK_SHIFT )
if nKey == VK_TAB .and. ::oWnd != nil .and. GetKeyState( VK_SHIFT ) .and. ::oWnd:GoPrevCtrl( ::hWnd )
return 0
endif
// AS 12/06/2007 Only process tab if there are controls to do it for
// if nKey == VK_TAB .and. ::oWnd != nil
if nKey == VK_TAB .and. ::oWnd != nil .and. ::oWnd:GoNextCtrl( ::hWnd )
return 0
endif
METHOD GoNextCtrl( hCtrl ) CLASS TWindow
local hCtlNext := NextDlgTab( ::hWnd, hCtrl )
local lRetval := .f.
::hCtlFocus = hCtlNext
if ! Empty( ::aControls ) .and. hCtrl == ::LastActiveCtrl():hWnd //ATail( ::aControls ):hWnd
if ! Empty( ::oWnd ) .and. ;
( Upper( ::oWnd:ClassName() ) == "TFOLDER" .or. ;
Upper( ::oWnd:ClassName() ) == "TPAGES" )
hCtlNext = NextDlgTab( ::oWnd:oWnd:hWnd, ::oWnd:hWnd )
::hCtlFocus = hCtrl
endif
endif
// Fix for Combobox with Dropdown by IOZ 12/06/00
if hCtlNext == hCtrl .and. Upper(getclassname(hCtrl)) == "EDIT"
hCtlNext := NextDlgTab( GetParent(::hWnd), hCtrl )
endif
if hCtlNext != hCtrl .and. hCtlNext != 0
SetFocus( hCtlNext )
lRetval := .t.
endif
return lRetval
//----------------------------------------------------------------------------//
METHOD GoPrevCtrl( hCtrl ) CLASS TWindow
local hCtlPrev := NextDlgTab( ::hWnd, hCtrl, .t. )
local n, cFoldName
local lRetval := .f.
#ifdef __CLIPPER__
cFoldName = "TFOLDER"
#else
cFoldName = "SYSTABCONTROL32"
#endif
::hCtlFocus = hCtlPrev
if ! Empty( ::aControls ) .and. hCtrl == ::FirstActiveCtrl():hWnd //::aControls[ 1 ]:hWnd
if ! Empty( ::oWnd ) .and. ;
( Upper( ::oWnd:ClassName() ) == "TFOLDER" .or. ;
Upper( ::oWnd:ClassName() ) == "TPAGES" )
hCtlPrev = NextDlgTab( ::oWnd:oWnd:hWnd, ::oWnd:hWnd, .t. )
::hCtlFocus = hCtrl
endif
endif
If hCtlPrev != hCtrl .and. hCtlPrev != 0
If Upper( GetClassName( hCtlPrev ) ) == cFoldName .or. ;
Upper( GetClassName( hCtlPrev ) ) == "TPAGES"
n = AScan( ::aControls, { | o | o:hWnd == hCtlPrev } )
if n > 0
::aControls[ n ]:aDialogs[ ::aControls[ n ]:nOption ]:LastActiveCtrl():SetFocus()
lRetval := .t.
endif
else
SetFocus( hCtlPrev )
lRetval := .t.
endif
endif
return lRetval