TGet Spinner Bug?

TGet Spinner Bug?

Postby Ugo » Wed Jan 04, 2006 4:28 pm

Hi fw's
I found a bug in spinner clause of Tget class

in first time work correctly but if you test up, after down to -1 and up the up see only 0, 1, 0, 1 ...

Test this code:
Code: Select all  Expand view
#include "FiveWin.ch"
//----------------------------------------------------------------------------//
function Main()
   LOCAL oDlg, oGet, nVal := 0
   DEFINE DIALOG oDlg
   @ 2,1 GET oGet VAR nVal OF oDlg SIZE 50, 12 SPINNER
   ACTIVATE DIALOG oDlg
   RETURN Nil
//------------------------------------------------------------------------------
Ciao, best regards,
Ugo
User avatar
Ugo
 
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy

Re: TGet Spinner Bug?

Postby Enrico Maria Giordano » Wed Feb 15, 2006 9:31 pm

I don't know why but the following fix seems to work:

Code: Select all  Expand view
METHOD ScrollNumber( nDirection ) CLASS TGet

   LOCAL nValue, nDec, nPos

   #ifndef __XPP__
      nValue := ::Value
   #else
      nValue := ::VarGet()
   #endif

   nPos := ::nPos

   if !Empty( ::oGet:DecPos ) .and. nPos >= ::oGet:DecPos
      nDec   := Max( 1, nPos - ::oGet:DecPos - 1 )
      If nDirection > 0
         nValue += 1 / ( 10 ^ nDec )
      else
         nValue -= 1 / ( 10 ^ nDec )
      Endif
   else
      nValue += nDirection
   endif

   if nDirection > 0
      if ::bMax != NIL .and. nValue > Eval( ::bMax )
         MessageBeep()
      else
         ::cText( nValue )
      endif
   else
      if ::bMin != NIL .and. nValue < Eval( ::bMin )
         MessageBeep()
      else
         ::cText( nValue )
      endif
   endif

   ::oGet:KillFocus()
   ::oGet:SetFocus()
   ::SetPos( nPos )

RETURN nil


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: TGet Spinner Bug?

Postby Enrico Maria Giordano » Wed Feb 15, 2006 9:32 pm

EnricoMaria wrote:I don't know why but the following fix seems to work:

Code: Select all  Expand view
METHOD ScrollNumber( nDirection ) CLASS TGet

   LOCAL nValue, nDec, nPos

   #ifndef __XPP__
      nValue := ::Value
   #else
      nValue := ::VarGet()
   #endif

   nPos := ::nPos

   if !Empty( ::oGet:DecPos ) .and. nPos >= ::oGet:DecPos
      nDec   := Max( 1, nPos - ::oGet:DecPos - 1 )
      If nDirection > 0
         nValue += 1 / ( 10 ^ nDec )
      else
         nValue -= 1 / ( 10 ^ nDec )
      Endif
   else
      nValue += nDirection
   endif

   if nDirection > 0
      if ::bMax != NIL .and. nValue > Eval( ::bMax )
         MessageBeep()
      else
         ::cText( nValue )
      endif
   else
      if ::bMin != NIL .and. nValue < Eval( ::bMin )
         MessageBeep()
      else
         ::cText( nValue )
      endif
   endif

   ::oGet:KillFocus() //EMG
   ::oGet:SetFocus() //EMG
   ::SetPos( nPos )

RETURN nil


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: TGet Spinner Bug?

Postby Enrico Maria Giordano » Wed Feb 15, 2006 9:33 pm

I don't know why but the following fix seems to work:

Code: Select all  Expand view
METHOD ScrollNumber( nDirection ) CLASS TGet

   LOCAL nValue, nDec, nPos

   #ifndef __XPP__
      nValue := ::Value
   #else
      nValue := ::VarGet()
   #endif

   nPos := ::nPos

   if !Empty( ::oGet:DecPos ) .and. nPos >= ::oGet:DecPos
      nDec   := Max( 1, nPos - ::oGet:DecPos - 1 )
      If nDirection > 0
         nValue += 1 / ( 10 ^ nDec )
      else
         nValue -= 1 / ( 10 ^ nDec )
      Endif
   else
      nValue += nDirection
   endif

   if nDirection > 0
      if ::bMax != NIL .and. nValue > Eval( ::bMax )
         MessageBeep()
      else
         ::cText( nValue )
      endif
   else
      if ::bMin != NIL .and. nValue < Eval( ::bMin )
         MessageBeep()
      else
         ::cText( nValue )
      endif
   endif

   ::oGet:KillFocus()
   ::oGet:SetFocus()
   ::SetPos( nPos )

RETURN nil


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: TGet Spinner Bug?

Postby Enrico Maria Giordano » Wed Feb 15, 2006 9:33 pm

I don't know why but the following fix seems to work:

Code: Select all  Expand view
METHOD ScrollNumber( nDirection ) CLASS TGet

   LOCAL nValue, nDec, nPos

   #ifndef __XPP__
      nValue := ::Value
   #else
      nValue := ::VarGet()
   #endif

   nPos := ::nPos

   if !Empty( ::oGet:DecPos ) .and. nPos >= ::oGet:DecPos
      nDec   := Max( 1, nPos - ::oGet:DecPos - 1 )
      If nDirection > 0
         nValue += 1 / ( 10 ^ nDec )
      else
         nValue -= 1 / ( 10 ^ nDec )
      Endif
   else
      nValue += nDirection
   endif

   if nDirection > 0
      if ::bMax != NIL .and. nValue > Eval( ::bMax )
         MessageBeep()
      else
         ::cText( nValue )
      endif
   else
      if ::bMin != NIL .and. nValue < Eval( ::bMin )
         MessageBeep()
      else
         ::cText( nValue )
      endif
   endif

   ::oGet:KillFocus() //EMG
   ::oGet:SetFocus() //EMG
   ::SetPos( nPos )

RETURN nil


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Re: TGet Spinner Bug?

Postby Ugo » Fri Feb 17, 2006 1:39 pm

EnricoMaria wrote:I don't know why but the following fix seems to work:

Code: Select all  Expand view
METHOD ScrollNumber( nDirection ) CLASS TGet

   LOCAL nValue, nDec, nPos
   ...
   ::oGet:KillFocus()
   ::oGet:SetFocus()
   ::SetPos( nPos )

RETURN nil


EMG


Enrico,
thank you, work perfectly!
Ciao, best regards,
Ugo
User avatar
Ugo
 
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy

Re: TGet Spinner Bug?

Postby Ugo » Fri Feb 17, 2006 1:40 pm

EnricoMaria wrote:Sorry... :-(

EMG


Why? :D
Ciao, best regards,
Ugo
User avatar
Ugo
 
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy

Re: TGet Spinner Bug?

Postby Enrico Maria Giordano » Fri Feb 17, 2006 2:03 pm

Sorry for the repeated post.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: TGet Spinner Bug?

Postby Ugo » Fri Feb 17, 2006 3:44 pm

EnricoMaria wrote:Sorry for the repeated post.

EMG


Nothing for me!!!
:D
Ciao, best regards,
Ugo
User avatar
Ugo
 
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 74 guests