TGET behavior (Antonio)

TGET behavior (Antonio)

Postby byte-one » Tue Jan 08, 2019 2:43 pm

In method createbutton() is this line
Code: Select all  Expand view
::oBtn:bAction := {|| Eval( oThis:bAction, oThis ),oThis:SetFocus() }

It respects not the present data ::lKeepFocus!! Should be:
Code: Select all  Expand view
::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.
Last edited by byte-one on Thu Jan 10, 2019 9:32 am, edited 1 time in total.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: TGET behavior (Antonio)

Postby byte-one » Thu Jan 10, 2019 9:31 am

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!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: TGET behavior (Antonio)

Postby byte-one » Sat Jan 12, 2019 3:02 pm

I add this code to method createbutton() after line 943 in FWH 18/12
Code: Select all  Expand view
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
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: TGET behavior (Antonio)

Postby Antonio Linares » Sat Jan 12, 2019 5:32 pm

Dear Günther,

Is it fully backwards compatible ?

Will we break someone else code ?
regards, saludos

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

Re: TGET behavior (Antonio)

Postby byte-one » Sat Jan 12, 2019 7:34 pm

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.
Last edited by byte-one on Sun Jan 13, 2019 7:08 pm, edited 1 time in total.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: TGET behavior (Antonio)

Postby byte-one » Sun Jan 13, 2019 7:18 pm

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.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: TGET behavior (Antonio)

Postby byte-one » Mon Jan 14, 2019 3:31 pm

Adapted code to respect oJump if present.
Code: Select all  Expand view
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
 
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: TGET behavior (Antonio)

Postby Rick Lipkin » Mon Jan 14, 2019 4:39 pm

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 view

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
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Willi Quintana and 76 guests