Problema en la clase button

Problema en la clase button

Postby fgondi » Fri Aug 29, 2008 11:04 am

En el siguiente ejemplo:
Code: Select all  Expand view
#include 'Fivewin.ch'

function Main()

LOCAL oDlg
LOCAL oGet1, oGet2, oGet3, oBtn
LOCAL cVar1 := 'ABCDEF '
LOCAL cVar2 := SPACE( 8 )
LOCAL cVar3 := SPACE( 8 )

DEFINE DIALOG oDlg FROM 0, 0 TO 10, 30

@ 1, 1 GET oGet1 VAR cVar1 SIZE 30,12 PIXEL Valid ( MsgInfo('1'), .T. )

@ 40,50 BUTTON oBtn PROMPT '&Test' SIZE 30, 20 PIXEL

ACTIVATE DIALOG oDlg CENTER

return NIL


Al pulsar intro en el get debe pasar por el valid del mismo, osea ejecutar msgInfo('1').

Sin embargo, si pulsamos en el botón y luego volvemos al get ya no ejecuta el valid.

Comprobando el código he visto que el método "FWLostFocus" de la clase control llama a lValid en el caso de que ::oWnd:lValidating sea nil o falso
Code: Select all  Expand view
METHOD FWLostFocus( hCtlFocus ) CLASS TControl

   local oWnd, oCtl

   if ::oWnd:lValidating == nil .or. ! ::oWnd:lValidating // FW++ lValidating nil sometimes
      ::oWnd:lValidating = .t.
...


Pero en el método "Click" de la clase button se iguala lValidating a true y no se vuelve a pasar a nil o a falso
Code: Select all  Expand view
METHOD Click() CLASS TButton

   if ! ::lProcessing
   
      ::lProcessing = .t.
     
      if ::bWhen != nil .and. ! Eval( ::bWhen )
         ::lProcessing = .f.
         return nil
      endif   

      ::oWnd:lValidating = .T.
...

Por lo que es normal que no se vuelva a ejecutar los valid's
Un saludo
Fernando González Diez
ALSIS Sistemas Informáticos
User avatar
fgondi
 
Posts: 694
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España

Postby Antonio Linares » Sat Aug 30, 2008 6:21 pm

Fernando,

Tienes toda la razón :-) Es un bug que se ha introducido en 8.08 al arreglar las diferencias entre pulsar un botón y pulsar su acelerador (hotkey).

El código correcto sería en Class TButton Method Click():
Code: Select all  Expand view
METHOD Click() CLASS TButton

   if ! ::lProcessing
   
      ::lProcessing = .t.
     
      if ::bWhen != nil .and. ! Eval( ::bWhen )
         ::lProcessing = .f.
         return nil
      endif   

      if GetFocus() != ::hWnd
         ::oWnd:lValidating = .T.
         SetFocus( ::hWnd )
         ::oWnd:lValidating = .F.   
      endif
      ...


Asi tu ejemplo ya funciona correctamente. Muchas gracias por detectarlo y comentárnoslo :-)
regards, saludos

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


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 46 guests