Page 1 of 1
TGet Spinner Bug?
Posted: Wed Jan 04, 2006 4:28 pm
by Ugo
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
#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
//------------------------------------------------------------------------------
Re: TGet Spinner Bug?
Posted: Wed Feb 15, 2006 9:31 pm
by Enrico Maria Giordano
I don't know why but the following fix seems to work:
Code: Select all
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
Re: TGet Spinner Bug?
Posted: Wed Feb 15, 2006 9:32 pm
by Enrico Maria Giordano
EnricoMaria wrote:I don't know why but the following fix seems to work:
Code: Select all
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
Re: TGet Spinner Bug?
Posted: Wed Feb 15, 2006 9:33 pm
by Enrico Maria Giordano
I don't know why but the following fix seems to work:
Code: Select all
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
Re: TGet Spinner Bug?
Posted: Wed Feb 15, 2006 9:33 pm
by Enrico Maria Giordano
I don't know why but the following fix seems to work:
Code: Select all
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
Re: TGet Spinner Bug?
Posted: Wed Feb 15, 2006 9:34 pm
by Enrico Maria Giordano
Sorry...
EMG
Re: TGet Spinner Bug?
Posted: Fri Feb 17, 2006 1:39 pm
by Ugo
EnricoMaria wrote:I don't know why but the following fix seems to work:
Code: Select all
METHOD ScrollNumber( nDirection ) CLASS TGet
LOCAL nValue, nDec, nPos
...
::oGet:KillFocus()
::oGet:SetFocus()
::SetPos( nPos )
RETURN nil
EMG
Enrico,
thank you, work perfectly!
Re: TGet Spinner Bug?
Posted: Fri Feb 17, 2006 1:40 pm
by Ugo
EnricoMaria wrote:Sorry...
EMG
Why?
Re: TGet Spinner Bug?
Posted: Fri Feb 17, 2006 2:03 pm
by Enrico Maria Giordano
Sorry for the repeated post.
EMG
Re: TGet Spinner Bug?
Posted: Fri Feb 17, 2006 3:44 pm
by Ugo
EnricoMaria wrote:Sorry for the repeated post.
EMG
Nothing for me!!!