Touch & Click problem in ver 2 ???

boten

Active Member
Licensed User
Longtime User
This works great in version 1.x but not in version 2.

(detect both touch & Longclick)

B4X:
Sub Panel1_Touch (Action As Int, X As Float, Y As Float) As Boolean 'Return True to consume the event
    Log(x)
    Return False
End Sub
Sub Panel1_LongClick
    Log("long")
End Sub
 

boten

Active Member
Licensed User
Longtime User
Tried the code you posted in another thread (with no modifications)
B4X:
Sub Process_Globals 'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals 'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
    Dim TransparentPanelOnTop As Panel
    Dim Button1 As Button
    Dim Button2 As Button
    Dim Label1 As Label
    Dim PositionX As Float
    Dim PositionY As Float
End Sub
Sub Activity_Create(FirstTime As Boolean)
    Label1.Initialize("Label1")
    Button1.Initialize("Button1")
    Button2.Initialize("Button2")
    TransparentPanelOnTop.Initialize("") 'remove the event name parameter
    Label1.Text = "Waiting for click..."
    Button1.Text = "I am a Button1 CLICK ME"
    Button2.Text = "I am a Button2 CLICK ME"
    Activity.AddView(Label1,10,10,Activity.Width - 20,60)
    Activity.AddView(Button1,10,100,Activity.Width - 20,60)
    Activity.AddView(Button2,10,180,Activity.Width - 20,60)
    Activity.AddView(TransparentPanelOnTop,0,0,100%x,1 00%y)
    TransparentPanelOnTop.Color = Colors.Transparent
    TransparentPanelOnTop.BringToFront
    Dim r As Reflector
    r.Target = TransparentPanelOnTop
    r.SetOnTouchListener( "TransparentPanelOnTop_Touch")
End Sub
Sub Activity_Resume

End Sub
Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub TransparentPanelOnTop_Touch (viewtag As Object, Action As Int, x As Float, Y As Float, motionevent As Object) As Boolean 'Return True to consume the event
    If Action = Activity.ACTION_DOWN Then
        PositionX = x
        PositionY = Y
        Return False
    End If
End Sub
Sub Button1_Click
    Label1.Text = "You Clicked Button1 with positions : X = " & PositionX & " Y = " & PositionY
End Sub
Sub Button2_Click
    Label1.Text = "You Clicked Button2 with positions : X = " & PositionX & " Y = " & PositionY
End Sub


and got Sub transparentpanelontop_touch signature does not match expected signature

full msg:
B4X:
java.lang.Exception: Sub transparentpanelontop_touch signature does not match expected signature.
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:172)
   at anywheresoftware.b4a.BA.raiseEvent(BA.java:154)
   at anywheresoftware.b4a.agraham.reflection.Reflection$7.onTouch(Reflection.java:1026)
   at android.view.View.dispatchTouchEvent(View.java:3762)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:897)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
   at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1671)
   at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
   at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
   at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1655)


   at android.view.ViewRoot.handleMessage(ViewRoot.java:1785)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:123)
   at android.app.ActivityThread.main(ActivityThread.java:4627)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:521)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
   at dalvik.system.NativeStart.main(Native Method)
java.lang.Exception: Sub transparentpanelontop_touch signature does not match expected signature.

any ideas?
 
Upvote 0

boten

Active Member
Licensed User
Longtime User
Works fine here. Which version of Reflection library are you using? Should be 2.20.
Was using earlier version. D/L'ed 2.2 and works fine. Thx.
BTW - finding libraries' newest version required looking for it in the forum. Is there somewhere all libs can be D/L'ed , perhaps next to the documentatin link?

Your layout doesn't look good because you are not using dip units.
your very code, man.:)
 
Upvote 0
Top