FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour :Click() error when TButton is disabled
Posts: 252
Joined: Tue Oct 25, 2005 02:48 PM

:Click() error when TButton is disabled

Posted: Thu May 25, 2006 11:29 PM

Antonio, I found a little bug in TButton class using bWhen clause and Click method:
If bWhen clause is invalid but I do oBtn:Click() the bAction referred to oBtn is executed, a little sample:

redefine button oBtn ... of oDlg action AnyAction()
oBtn:bWhen := {|| .F. }

oDlg:bKeyDown := {|k| if(k=VK_F9, oBtn:Click(),) } // F9 fire action

function AnyAction()
? "oBtn was clicked"
return( Nil )

To solve I did: (In TButton.prg)

METHOD Click() CLASS TButton
if ! ::lProcessing
if ::bWhen # Nil .and. ! eval( ::bWhen )
return( Nil )
endif
(...)


*** I don't tested if it occur in other button controls like TBtnBmp, etc.

Regards,
Maurilio

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

:Click() error when TButton is disabled

Posted: Fri May 26, 2006 06:16 AM
Maurilio,

Thanks :-)

This way seems a little better:
   if ! ::lProcessing
   
      ::lProcessing = .t.
      
      if ::bWhen != nil .and. ! Eval( ::bWhen ) 
         ::lProcessing = .f.
         return nil 
      endif    
      ...
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 252
Joined: Tue Oct 25, 2005 02:48 PM

:Click() error when TButton is disabled

Posted: Fri May 26, 2006 10:44 PM

Thanks, Antonio!

Regards,
Maurilio

Continue the discussion