Android Question Bug in B4A Fluidslider No Wrap

Discussion in 'Android Questions' started by mcqueccu, Jul 3, 2018.

  1. mcqueccu

    mcqueccu Active Member Licensed User

    I realised the Fluidslider here goes beyond the Max and Min Limit. Even though its label stops at the min and max value, value still increases when you continue to hold the slider when it reaches the ends.

    Note: Its same example provided, i just added the label to display the values and reduced the width of the slider

    [​IMG]
     

    Attached Files:

  2. Peter Simpson

    Peter Simpson Expert Licensed User

    You should have put this post on the original thread.

    UPDATE: I've just downloaded the FluidSlider, it appears to be working 100% here...
     
  3. mcqueccu

    mcqueccu Active Member Licensed User

    Forum Rule: Don't bump old thread....

    There was a warning about the thread being Old (More than 1 Month) that is why I created this new one
     
  4. Peter Simpson

    Peter Simpson Expert Licensed User

    Don't worry about the warning, you can post an apparent error on the original post for the author to look at.

    Anyway the slider is working on my test device, double check your label code and add Min/Max if you have to...
     
  5. mcqueccu

    mcqueccu Active Member Licensed User

    Attached is my example

    Code:
    Sub FluidSlider1_ChangeValue (Value As Int)
        Label1.Text = Value
    End Sub
     

    Attached Files:

  6. Peter Simpson

    Peter Simpson Expert Licensed User

    @mcqueccu What device are you using, also what happens if you replace the original sub with this sub, does it make any difference to you?
    Code:
    Private Sub Panel_Touch (Action As Int, X As Float, Y As Float)
        
    Select Action
            
    Case 0 ' ACTION_DOWN
                Dim P As Int = ((X / mBase.Width) * (MaxValue - MinValue)) + MinValue
                setValue(P, 
    True)
                
    If SubExists(mCallBack, mEventName & "_ChangeValue"Then CallSub2(mCallBack, mEventName & "_ChangeValue", p)
            
    Case 1 ' ACTION_UP
                Ball.SetLayoutAnimated(200, Ball.Left, mBase.Height / 2, mBase.Height / 2, mBase.Height / 2)
            
    Case 2 ' ACTION_MOVE
                Dim P As Int = ((X / mBase.Width) * (MaxValue - MinValue)) + MinValue
                
    If P < 0 Then P = 0 : If P > 100 Then P = 100
                setValue(P, 
    True)
                
    If SubExists(mCallBack, mEventName & "_ChangeValue"Then CallSub2(mCallBack, mEventName & "_ChangeValue", p)
            
    Case 3 ' Error
        End Select
    End Sub
    Enjoy...
     
    Last edited: Jul 3, 2018
    Johan Schoeman and DonManfred like this.
  7. mcqueccu

    mcqueccu Active Member Licensed User

    Works Perfectly. :D
     
  8. mcqueccu

    mcqueccu Active Member Licensed User

    The solution above works perfectly if you are selecting between 0 and 100.
    But if you set your Minimum Value say 10, and maximum value say 91, the slider still goes to 0 or to 100 irrespective of the Limits.

    This Now works for me:

    Code:
    Private Sub Panel_Touch (Action As Int, X As Float, Y As Float)
        
    Select Action
            
    Case 0 ' ACTION_DOWN
                Dim P As Int = ((X / mBase.Width) * (MaxValue  -MinValue)) + MinValue
              
    '  If P < 0 Then P  =0 : If P > 100 Then P = 100
                  If P<MinValue Then p = MinValue : If p > MaxValue Then p = MaxValue '<-----------------------------
                setValue(P,True)
                
    If SubExists(mCallBack, mEventName & "_ChangeValue"Then CallSub2(mCallBack, mEventName & "_ChangeValue", p)
            
    Case 1 ' ACTION_UP
                Ball.SetLayoutAnimated(200, Ball.Left, mBase.Height/2, mBase.Height/2, mBase.Height/2)
            
    Case 2 ' ACTION_MOVE
                Dim P As Int = ((X / mBase.Width) * (MaxValue - MinValue)) + MinValue
                
    'If P<0 Then P=0 : If P> 100 Then P=100
                If P<MinValue Then p = MinValue : If p > MaxValue Then p = MaxValue    '<-----------------------------
                setValue(P,True)
                
    If SubExists(mCallBack, mEventName & "_ChangeValue"Then CallSub2(mCallBack, mEventName & "_ChangeValue", p)
            
    Case 3 ' Error
        End Select
    End Sub
     
    Kope likes this.
  9. Peter Simpson

    Peter Simpson Expert Licensed User

    Here you go @mcqueccu , the following code covers all set ranges, you can completely remove one of the lines.
    Code:
    Private Sub Panel_Touch (Action As Int, X As Float, Y As Float)
        
    Select Action
            
    Case 0 ' ACTION_DOWN
                Dim P As Int = ((X / mBase.Width) * (MaxValue - MinValue)) + MinValue
                
    'If P < 0 Then P = 0 : If P > 100 Then P = 100
                setValue(P, True)
                
    If SubExists(mCallBack, mEventName & "_ChangeValue"Then CallSub2(mCallBack, mEventName & "_ChangeValue", p)
            
    Case 1 ' ACTION_UP
                Ball.SetLayoutAnimated(200, Ball.Left, mBase.Height / 2, mBase.Height / 2, mBase.Height / 2)
            
    Case 2 ' ACTION_MOVE
                Dim P As Int = ((X / mBase.Width) * (MaxValue - MinValue)) + MinValue
                
    If P < MinValue Then P = MinValue : If P > MaxValue Then P = MaxValue
                setValue(P, 
    True)
                
    If SubExists(mCallBack, mEventName & "_ChangeValue"Then CallSub2(mCallBack, mEventName & "_ChangeValue", p)
            
    Case 3 ' Error
        End Select
    End Sub
    Enjoy...
     
    Kope and Johan Hormaza like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice