Android Question B4XSeekBar Steps

The effect is not smooth, if you drag the knob.

Code:
Sub B4XSeekBar1_ValueChanged (Value As Int)
    B4XSeekBar1.Value = Round (Value/10) * 10
    Log("Value: " & B4XSeekBar1.Value)
End Sub
 
Upvote 0
You can get it to snap on mouse release by adding a listener to the basepane of the seekbar:

Code:
    Dim Jo As JavaObject = B4XSeekBar1.mBase
    Dim O As Object = Jo.CreateEventFromUI("javafx.event.EventHandler","Seekbar",Null)
    Jo.RunMethod("setOnMouseReleased",Array(O))

Then adding Jorge's code to the mouse released event callback:
Code:
Sub SeekBar_Event (MethodName As String, Args() As Object) As Object
    B4XSeekBar1.Value = Round (B4XSeekBar1.Value/10) * 10
    Log("Value: " & B4XSeekBar1.Value)
End Sub

Not much different but it's a little nicer experience maybe.
 
Upvote 0
Hmm, sorry it seems that this option is not available for B4a, the touch listener is in use by the Seekbar, we can't listen to it and use the seekbar.
 
Upvote 0
Back
Top