Android Question Piano Multiple_Touch

Douglas Farias

Expert
Licensed User
10854152_878964012133816_817006353_o.jpg

Hi all!
i made this piano with panels, and now i want to add multiple touch at this panels.
i made all panels on the design menu. total = 27 panels

how can i make a multiple touch for all panels? for example, sometimes i need to press 3 or 4 keys at same time, with gesture lib this dont work, panels, or buttons i cant press 2 + at sime time

how can i press 3 panels on the same time without problem?


here is a example with 2 panels only
B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: SoundPool
    #VersionCode: 1
    #VersionName:
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

'Activity module
Sub Process_Globals
End Sub

Sub Globals
    Private Panel2 As Panel
    Private Panel3 As Panel
    Private gd As Gestures
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    gd.SetOnTouchListener(Panel2, "GesturesTouch")
    gd.SetOnTouchListener(Panel3, "GesturesTouch2")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub GesturesTouch(View As Object, PointerID As Int, Action As Int, X As Float, Y As Float) As Boolean
    Panel2.Color = Colors.RGB(200,200,200)
    If Action = 1 Then Panel2.Color = Colors.RGB(255,255,255)
    Return True
End Sub

Sub GesturesTouch2(View As Object, PointerID As Int, Action As Int, X As Float, Y As Float) As Boolean
    Panel3.Color = Colors.RGB(200,200,200)
    If Action = 1 Then Panel3.Color = Colors.RGB(255,255,255)
    Return True
End Sub
this is incorrect, i can press only one per time, how can i make to press 2 or + panels at same time using gesture or only panels?
 

stevel05

Expert
Licensed User
See your thread: http://www.b4x.com/android/forum/threads/sound-sugestion.38896/ and my example project in post #10.

You can use the gesture library on a panel, you then need to find out which note should be triggered when the gesture is received, that's where the rect's (wrapped in a screenobject) are used to simplify the process.

BTW, the image of a piano is incorrect, assuming that the leftmost note is a C, then the third black note should not be there, there is no E#/Fb key on a piano.
 
Last edited:

Douglas Farias

Expert
Licensed User
ho yes, is only a test.

You can use the gesture library on a panel, you then need to find out which note should be triggered when the gesture is received, that's where the rect's (wrapped in a screenobject) are used to simplify the process.
no change to make with panels using the design menu?

and with
CreateObject(0%x,0%y,12%x,98%y,File.DirAssets,"snare.mp3",Colors.White,False)

its possible make corner radius = 5 ?
like panels in the image?
 
Last edited:

stevel05

Expert
Licensed User
For completeness, you should also be able to use buttons to achieve this from Honeycomb and up using the Down and Up events instead of the click event. The added benefit would be that you can use the buttons state to display different images i.e. key depressed, with little additional work.
 
Top