iOS Question Panel2.TOUCH_ACTION_DOWN is canceled when using X2Touch on a PanelforTouch - B4i

developer_123

Active Member
Licensed User
Longtime User
Good day. Actually I didn't know whether to place this query in the Game or B4i forum, since it only happens to me with B4i, and as the title of this thread says, when creating a new Panel1 as B4XView and trying to use the events of this new panel TOUCH_ACTION_DOWN, TOUCH_ACTION_MOVE or TOUCH_ACTION_UP these do not work, the Iphone never enters to process these routines. I tried declaring Panel1 As Panel and using ACTION_DOWN, ACTION_MOVE, ACTION_UP, but the same thing happens, that is nothing.

I infer that this may be happening since the touch events are being handled by X2Touch from Panelfortouch whose event name in the designer was set to Panel only.

What can I do to correct this, and be able to use the touch events of the panels. ??

This only happens with B4I since B4J and B4A do correctly take touch events from other Panels.
 

developer_123

Active Member
Licensed User
Longtime User
Please create a small project and upload it.
I used the Lines project as an example, which uses the X2Touch touch event, and I simply created a panel and a label, in the 3 platforms the same code and in the designer the same. when touching the panel the touch event routines for the Panel1 do not work for IOS. I relate wetransfer link since it did not allow me to upload it due to size (3 mb). (I'm testing in a Iphone 6)

 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I used the Lines project as an example,
This is a very cool example :)

1. Check the note in the Initialize method:

1643695493094.png

(thouch = though - fixed).

2. It is not a good idea to handle events outside of the game loop.
3. The "X2" way to implement is with:
B4X:
Public Sub Tick (GS As X2GameStep)
    HandleTouch 'not related to this question
    Dim touch As X2Touch = Multitouch.GetSingleTouch(Panel1)
    If touch.IsInitialized Then
        If touch.EventCounter = 0 Then
            Label1.Text="DOWN"
        Else If touch.FingerUp Then
            Label1.Text="UP"
        Else
            Label1.Text="IS MOVING"
        End If
    End If
End Sub
And don't forget to set the Event Name of Panel1 to Panel.
 
Upvote 0

developer_123

Active Member
Licensed User
Longtime User
This is a very cool example :)

1. Check the note in the Initialize method:

View attachment 124996
(thouch = though - fixed).

2. It is not a good idea to handle events outside of the game loop.
3. The "X2" way to implement is with:
B4X:
Public Sub Tick (GS As X2GameStep)
    HandleTouch 'not related to this question
    Dim touch As X2Touch = Multitouch.GetSingleTouch(Panel1)
    If touch.IsInitialized Then
        If touch.EventCounter = 0 Then
            Label1.Text="DOWN"
        Else If touch.FingerUp Then
            Label1.Text="UP"
        Else
            Label1.Text="IS MOVING"
        End If
    End If
End Sub
And don't forget to set the Event Name of Panel1 to Panel.
EreL, thnaks!. I'm testing this code, and works with B4J and B4i, but now is not working in B4A. I can see inside the Lines example there is this code for B4j and b4i, but no for b4A
B4X:
#If B4J
Private Sub Panel_Touch (Action As Int, X As Float, Y As Float)
    Multitouch.B4JDelegateTouchEvent(Sender, Action, X, Y)
End Sub
#Else If B4i
Private Sub Panel_Multitouch (Stage As Int, Data As Object)
    Multitouch.B4iDelegateMultitouchEvent(Sender, Stage, Data)
End Sub
#End If

Does this exist for B4A? I understand that it should work for the 3 platforms just as it works for Panelfortouch, but I have done it identically as you suggested and now the one that does not work is b4A. Could I have missed something?

WETRANSFER link

 
Last edited:
Upvote 0

developer_123

Active Member
Licensed User
Longtime User
1. Make sure to set the event name to Panel.
2. I forgot to write that you should add it on this line:
B4X:
Multitouch.Initialize(B4XPages.MainPage, Array(PanelForTouch, Panel1))
Have you done both?
yes, that was it, I needed to initialize it. Relating Panel1. Thanks , works fine!
 
Upvote 0
Top