Bug in TButton

Post Reply
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Bug in TButton

Post by Enrico Maria Giordano »

The following sample shows the problem. Try to put any character in the GET and then hit ALT-C. You will see that the DIALOG won't close. On the contrary, if you click on the button the DIALOG will close.

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVar := SPACE( 20 )

    DEFINE DIALOG oDlg

    @ 1, 1 GET cVar;
           VALID !EMPTY( cVar )

    @ 3, 1 BUTTON "&Close";
           ACTION oDlg:End()

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL
EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Enrico,

On a first review it looks as a Harbour vs xharbour related issue.

With Harbour it works ok :)

It seems a difference between Harbour/xharbour Class TGet.
Last edited by Antonio Linares on Sun Feb 19, 2006 7:24 pm, edited 1 time in total.
regards, saludos

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

Post by Antonio Linares »

This way it works:

Code: Select all

    @ 1, 1 GET cVar; 
           VALID ( oDlg:aControls[ 1 ]:Assign(), !EMPTY( cVar ) ) 
So it seems that with xharbour the ::oGet DATA has not been assigned, thats why it remains "empty".
regards, saludos

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

Post by Antonio Linares »

This is a fix:

Code: Select all

METHOD lValid() CLASS TGet

   local lRet := .t.

   if ::oGet:BadDate
      ::oGet:KillFocus()
      ::oGet:SetFocus()
      MsgBeep()
      return .f.
   else
      ::oGet:Assign()    // New !!!
      if ValType( ::bValid ) == "B"
         lRet := Eval( ::bValid, Self  )
         if ! lRet
            ::oWnd:nLastKey = 0
         endif
      endif
   endif

return lRet
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Thank you, but I suspect that some other problems is hiding under the wood... :-(

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Enrico,

Yes, we'll see.

The problem is that Class TGet is quite different from Harbour to xharbour.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Luis Krause
Posts: 59
Joined: Tue Oct 11, 2005 1:39 am
Location: Vancouver, Canada

Post by Luis Krause »

Antonio:

The last time I sent you a suggested fix in TGet [I forgot what it was
about :-) ], I pasted a modified version of ::EditUpdate() I've been using for several years now and in which I added the call to ::oGet:assign()
to ensure the Clipper/[x]Harbour buffer was always in sync with FW/FWH's.
That could be an alternate fix for this problem:

METHOD EditUpdate() CLASS TGet

if ::oGet:HasFocus
::DispText()
::oGet:Assign() // lkm
endif

::SetPos( ::oGet:Pos )

Return Self

Antonio Linares wrote:This is a fix:

Code: Select all

METHOD lValid() CLASS TGet

   local lRet := .t.

   if ::oGet:BadDate
      ::oGet:KillFocus()
      ::oGet:SetFocus()
      MsgBeep()
      return .f.
   else
      ::oGet:Assign()    // New !!!
      if ValType( ::bValid ) == "B"
         lRet := Eval( ::bValid, Self  )
         if ! lRet
            ::oWnd:nLastKey = 0
         endif
      endif
   endif

return lRet
Regards,

Luis
"May the Source be with GNU"
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Antonio Linares wrote:Enrico,

Yes, we'll see.

The problem is that Class TGet is quite different from Harbour to xharbour.
After some tests it seems all ok with your fix.

Thank you.

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Luis,

The fact is that Class TGet is different in Harbour and xharbour, thats why we need to asure that before we validate a GET, its related variable has been assigned. Placing it at lValid() is a way to be sure it gets done.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply