Page 1 of 1
TGET behavior (Antonio)
Posted: Tue Jan 08, 2019 2:43 pm
by byte-one
In method createbutton() is this line
Code: Select all | Expand
::oBtn:bAction := {|| Eval( oThis:bAction, oThis ),oThis:SetFocus() }
It respects not the present data ::lKeepFocus!! Should be:
Code: Select all | Expand
::oBtn:bAction := {|| ( Eval( oThis:bAction, oThis ), if( ::lKeepFocus, oThis:SetFocus(), nil ) ) }
as i cannot automatic go to next control after processing the oBtn:baction, if i need so.
Re: TGET behavior (Antonio)
Posted: Thu Jan 10, 2019 9:31 am
by byte-one
Antonio,
as the Button is an other way to input the value my idea is:
if lKeepfocus is false, to evaluate the oGet:bValid if present an then go to next control!
Re: TGET behavior (Antonio)
Posted: Sat Jan 12, 2019 3:02 pm
by byte-one
I add this code to method createbutton() after line 943 in FWH 18/12
Code: Select all | Expand
if !::lKeepFocus
::oBtn:bAction := {|| Eval( oThis:bAction, oThis ),oThis:refresh(),if(valtype(::bValid) == "B",; //if bvalid is "B"
if(Eval( ::bValid, oThis ),; //if bValid == .T.
::oWnd:gonextctrl(::hWnd),; //next control
oThis:Setfocus()),; //focus stay
::oWnd:gonextctrl(::hWnd)); //automatic next control
}
endif
Re: TGET behavior (Antonio)
Posted: Sat Jan 12, 2019 5:32 pm
by Antonio Linares
Dear Günther,
Is it fully backwards compatible ?
Will we break someone else code ?
Re: TGET behavior (Antonio)
Posted: Sat Jan 12, 2019 7:34 pm
by byte-one
Antonio, i think nobody has used ::lKeepFocus as it was not used in actual tget-code! But it saves keybord- or mouse activation in the case of exist ::oBtn in the get and is elegant.
I am also excite to add in the headerfile on GET and [ACTION[NONEXT]]. [NONEXT] sets ::lKeepfocus to .F.
Re: TGET behavior (Antonio)
Posted: Sun Jan 13, 2019 7:18 pm
by byte-one
Rick, you can use your code as before if you do not set ::lKeepFocus to .F.!
I want this behavior for example to put a date from a calendar and if the valid-clause is .T. the cursor steps to next control without using the keybord.
Re: TGET behavior (Antonio)
Posted: Mon Jan 14, 2019 3:31 pm
by byte-one
Adapted code to respect oJump if present.
Code: Select all | Expand
if !::lKeepFocus
::oBtn:bAction := {|| Eval( oThis:bAction, oThis ),oThis:refresh(),if(valtype(::bValid) == "B",; //if bvalid is "B"
if(Eval( ::bValid, oThis ),; //if bValid == .T.
(if(::oJump != nil,setfocus(::oJump:hWnd),::oWnd:gonextctrl(::hWnd))),; //next control or oJump
oThis:Setfocus()),; //focus stay
if(::oJump != nil,setfocus(::oJump:hWnd),::oWnd:gonextctrl(::hWnd))); //automatic next control or oJump
}
endif
Re: TGET behavior (Antonio)
Posted: Mon Jan 14, 2019 4:39 pm
by Rick Lipkin
Günther
I deleted my post after re-reading your initial post about oBtn ... here is the code I deleted that pertained to the oJump method ..
Code: Select all | Expand
REDEFINE GET oPosition VAR cPosition ID 142 of oGrps PICTURE "@!" BITMAP "find";
ACTION ( _PosGet( cMode,@cPosition,oPosition,oPositionAbbr,@cPositionAbbr,"BUTTON",;
oButt1,oButt2,oRsEmp ),;
oPositionAbbr:SetFocus(),oPositionAbbr:oJump := oPositionAbbr ) UPDATE
oPosition:lAdjustBtn := .t.
oPosition:bKeyDown := {|nK| if( nK==VK_RETURN,( ;
_PosGet( cMode,@cPosition,oPosition,oPositionAbbr,@cPositionAbbr,"FIELD",;
oButt1,oButt2,oRsEmp ),;
oOrganU:SetFocus(),oOrganU:oJump := oOrganU ), ) }
REDEFINE GET oPositionAbbr VAR cPositionAbbr ID 148 of oGRPS UPDATE //COLOR CLR_BLACK, 16053492 READONLY
In the above code .. tget is evaluating the bKeydown code block and traps the <enter> key .. thereby blocking the navigation to the next field .. I believe the above code was inspired my Antonio .. I mention oJump in my deleted post and noted that if was a bit clumsy and your solution seemed much more elegant .. Hope this post is relevant to your tget enhancement.
Rick Lipkin