Multitouch and Custom Seekbar..

rubino25

Member
Licensed User
Longtime User
Hi all .. I'm trying to make a custom SeekBar for the management of two values ​​to be transferred via bluetooth! I need to also implement multitouch! I searched the forum all the possible examples but I can't understand a lot .. I have seen examples of multitouch, but are difficult for me to understand and I can't find anything on custom SeekBar .. Could someone help me? Thanks ... :sign0148::sign0148:
 

rubino25

Member
Licensed User
Longtime User
I have to create a sort of "remote control" to control arduino via bluetooth. A first version is up and running, but I would like to enable multitouch and manage the movements as if it were a real remote control .. Then two vertical SeekBar for left and right channels, a few buttons and not much else.. I wish I could manage two SeekBar simultaneously .. This is the result for now .. But it does not satisfy me at all ..
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This code will help you get started:
B4X:
Sub Globals   
   Dim pnl As Panel
   Dim g As Gestures
   Dim cvs As Canvas
   Dim SeekBarsColors() As Int
   SeekBarsColors = Array As Int(Colors.Yellow, Colors.Blue)
End Sub

Sub Activity_Create(FirstTime As Boolean)
   pnl.Initialize("")
   Activity.AddView(pnl, 0, 0, 100%x, 100%y)
   g.SetOnTouchListener(pnl, "Pnl_GesturesTouch")
   cvs.Initialize(pnl)
End Sub
Sub Pnl_GesturesTouch(View As Object, PointerID As Int, Action As Int, x As Float, Y As Float) As Boolean
   For i = 0 To g.GetPointerCount - 1
      Dim x, y As Float
      x = g.GetX(i)
      y = g.GetY(i)
      If y > 100dip AND y < 200dip Then
         DrawSeekBar(0, x)
      Else If y > 200dip AND y < 300dip Then
         DrawSeekBar(1, x)
      End If
   Next
   Return True
End Sub

Sub DrawSeekBar(SeekBarNum As Int, X As Float)
   Dim r As Rect
   r.Initialize(0, 100dip + SeekBarNum * 100dip, 100%x, 100dip + SeekBarNum * 100dip + 100dip)
   cvs.DrawRect(r, Colors.Black, True, 0)
   pnl.Invalidate2(r)
   r.Right = X
   cvs.DrawRect(r, SeekBarsColors(SeekBarNum), True, 0)   
End Sub
It creates two simple seek bars which you can handle with two fingers:
SS-2012-02-12_11.15.27.png
 
Upvote 0
Top