Page 1 of 1

Focus problem with TGet class

Posted: Mon Mar 13, 2006 2:47 pm
by Maurilio Viana
Dear Antonio,

We detect a strange problem with gets when we have a sequence like
get1, get2, getN, pushbutton and getN have a valid/when condition or
when pushbutton depend of getN valid/when. For any cause that we couldn't
detect pushbutton don't get the focus. We couldn't isolate a little
situation when it occur but I detected that it occur only when we use
enter key to skip to next control. Using tab key the navigation by the
controls, validations and when is evaluated correctly.
I changed a bit the code from KeyChar method in window.prg to test if
tab OR enter was pressed to skip to next control as follow.
My focus problems was solved and I hope the similar
problem of another user too.

Code: Select all

METHOD KeyDown( nKey, nFlags ) CLASS TWindow

   local bKeyAction := SetKey( nKey )

   if nKey == VK_TAB .and. ::oWnd != nil .and. GetKeyState( VK_SHIFT )
      ::oWnd:GoPrevCtrl( ::hWnd )
      return 0
   endif

   if (nKey == VK_TAB .or. nKey == VK_RETURN) .and. ::oWnd != nil // <-- Here
      ::oWnd:GoNextCtrl( ::hWnd )
      return 0
   endif
(...)
Regards,
Maurilio

Posted: Mon Mar 13, 2006 4:11 pm
by James Bott
Maurilio,

Does this create a problem with the Enter key triggering the default pushbutton?

Remember that the Tab key is the Windows standard for moving from field to field. The Enter key was used in DOS apps. Most users are going to expect the Enter key to trigger the default pushbutton.

James

Posted: Tue Mar 14, 2006 10:04 pm
by Maurilio Viana
James,

My fault! I forgot to mention it can be used only by users that have these focus problems.
I donĀ“t tested with default pushbuttons yet.
In FWH 2.6 worked fine, when I migrate to 2.7 I had this focus problems when I use any sequence of when/valid clauses in gets and/or pushbuttons.

Regards,
Maurilio