Page 1 of 1

Different behaviour in FWH/FW in GET...ON CHANGE

Posted: Thu Feb 15, 2007 12:43 pm
by patrickmast2
Hello,

In Clipper, no matter what the ON CHANGE returns, TAB or ENTER positions the cursor in the next GET.
In xHarbour, the ON CHANGE needs to return .T. before ENTER brings the cursor to the next GET.

Please try this sample:

/*

oGet1 has an onChange wich does NOT return .T.
-> By changing value in oGet1 en pressing ENTER, cursor stays in oGet1 <<- WRONG
-> By changing value in oGet1 en pressing TAB, cursor goes to oGet2

oGet2 has an onChange wich DOES return .T.
-> By changing value in oGet2 en pressing ENTER, cursor goes to oGet3
-> By changing value in oGet2 en pressing TAB, cursor goes to oGet2

*/

#include "FiveWin.ch"

Function wfMain()
LOCAL oDlg
LOCAL oGet1, oGet2, oGet3
LOCAL cGet1, cGet2, cGet3:=""

cGet1:="Change this text en press Enter"
cGet2:="Change this text en press Enter"

DEFINE DIALOG oDlg TITLE "Test" FROM 0, 0 TO 300,400 PIXEL

@ 10, 10 GET oGet1 VAR cGet1 OF oDlg PIXEL SIZE 150, 10;
ON CHANGE (cGet3+="On Change cGet1: Cursor stays in oGet1!!"+CRLF, oGet3:Refresh()) ;
VALID (cGet3+="Valid cGet1"+CRLF, oGet3:Refresh(), .T.) ;

@ 30, 10 GET oGet2 VAR cGet2 OF oDlg PIXEL SIZE 150, 10;
ON CHANGE (cGet3+="On Change cGet2: Cursor goes to next field"+CRLF, oGet3:Refresh(), .T.) ;
VALID (cGet3+="Valid cGet2"+CRLF, oGet3:Refresh(), .T.) ;

@ 50, 10 GET oGet3 VAR cGet3 OF oDlg MEMO PIXEL SIZE 150, 50

ACTIVATE DIALOG oDlg CENTERED

RETURN NIL

--
Sincerely,

Patrick Mast
www.xHarbour.com

Posted: Thu Feb 15, 2007 3:45 pm
by Rochinha
Patrick

I made this simple modification in the TGET Class for me:

Code: Select all | Expand

METHOD KeyChar( nKey, nFlags ) CLASS TGet
      ...
      case nKey == VK_TAB .or. nKey == VK_RETURN
           if ::bChange != nil .and. ( ::oGet:Changed .or. ::oGet:UnTransform() != ::oGet:Original )
              lAccept = Eval( ::bChange, nKey, nFlags, Self )
              //if ValType( lAccept ) == "L" .and. lAccept // isolated
                 ::oWnd:GoNextCtrl( ::hWnd )
              //endif // isolated
           else
              ::oWnd:GoNextCtrl( ::hWnd )
           endif


Works for me, but in the library de problem continue.

Posted: Thu Feb 15, 2007 4:10 pm
by driessen
Patrick,

I am migrating my FW16-application to xHarbour and I just noticed today the same problem. It also happens when using the VALID clause.

Rochinha, thanks a lot for your help. I added the changed TGET.PRG to my PRG-files and it's working fine now.

Michel

Posted: Thu Feb 15, 2007 5:15 pm
by James Bott
Keep in mind that the Windows standard is to move from field to field with the Tab key and the Enter key triggers the default pushbutton which is usually the OK button. This allows users to enter data and close the dialog without using the mouse or tabbing through all the fields (as they had to do in DOS apps).

I know when converting DOS apps your users will be used to using the Enter key for field movement, and they WILL complain if you take this away. But most of the other applications they work with do not use the Enter key for movement so you will really being doing them a favor by making them get used to using the Tab key. In my experience you won't hear any more complaints after a week or two.

James

Posted: Thu Feb 15, 2007 5:46 pm
by Antonio Linares
This may be a more complete fix:

Code: Select all | Expand

METHOD KeyChar( nKey, nFlags ) CLASS TGet 
      ...
      case nKey == VK_TAB .or. nKey == VK_RETURN
           if ::bChange != nil .and. ( ::oGet:Changed .or. ::oGet:UnTransform() != ::oGet:Original )
              lAccept = Eval( ::bChange, nKey, nFlags, Self )
              if ValType( lAccept ) == "L"
                 if lAccept
                    ::oWnd:GoNextCtrl( ::hWnd )
                 endif
              else
                 ::oWnd:GoNextControl( ::hWnd )
              endif     
           else
              ::oWnd:GoNextCtrl( ::hWnd )
           endif

Posted: Thu Feb 15, 2007 8:49 pm
by patrickmast2
Thank you Antonio.

Posted: Sat Feb 17, 2007 6:34 am
by Rochinha
My thanks too!