iOS Question Unable to get touch events

cxbs

Active Member
Licensed User
Longtime User
Hello everyone!
I want to make a pop-up menu like this
However, the touch event cannot be obtained
I don't know where I missed it
Is it caused by nested panels!

thank you!

The above English is from translation software

B4X:
'Custom View class
#Event: ItemClicked (Item As MenuItem)

Sub Class_Globals
    Private mEventName As String 'ignore
    Private mCallBack As Object 'ignore
    Private mBase As WeakRef
    
    Private mMenuBase As Panel

End Sub

Public Sub Initialize (Callback As Object, EventName As String,mPanle As Panel)
    mEventName = EventName
    mCallBack = Callback
    mBase.Value=mPanle   
End Sub

Private Sub Base_Resize (Width As Double, Height As Double)
    
End Sub

Public Sub Show
    Dim mBox As Panel
    mBox.Initialize("")
    mBox.Color=Colors.White
    mBox.SetShadow(Colors.Black,2dip,2dip,0.5,False)
    Dim nativeObjectInstance As NativeObject
    nativeObjectInstance = mBox
    nativeObjectInstance.GetField ("layer").SetField ("shadowRadius", 10)
    
    Dim SV As ScrollView
    SV.Initialize("",200dip,190dip)
    mBox.AddView(SV,0,0,200dip,190dip)
    
    Dim mPan As Panel
    mPan.Initialize("Item")
    Dim lab As Label
    lab.Initialize("")
    lab.Text="Item Test1"
    mPan.AddView(lab,15dip,5dip,130dip,50dip)
        
    SV.Panel.AddView(mPan,0,10dip,190dip,50dip)

    SV.ContentHeight=190dip

    mMenuBase.Initialize("Base")
    'mMenuBase.Color=Colors.Yellow
    mMenuBase.AddView(mBox,50dip,200dip,200dip,190dip)

    Dim tBase As Panel=mBase.Value
    tBase.AddView(mMenuBase,0,0,tBase.Width,tBase.Height)

End Sub

Private Sub Item_Touch(Action As Int, X As Float, Y As Float)
'Private Sub Item_Click
    Dim Pan As Panel=Sender
    If SubExists(mCallBack, mEventName & "_ItemClicked",1) Then
        CallSub2(mCallBack,mEventName & "_ItemClicked",Pan.Tag)
    End If
    Close
End Sub


Private Sub Base_Touch(Action As Int, X As Float, Y As Float)
'Private Sub Base_Click
    Close
End Sub

Public Sub Close
    mMenuBase.RemoveAllViews
    mMenuBase.RemoveViewFromParent
    mMenuBase.Initialize("")
End Sub

B4X:
Sub Button1_Click
    Dim mMenu As PopupMenu
    mMenu.Initialize(Me,"menu",Page1.RootPanel)
    mMenu.Show
End Sub
 

Attachments

  • NoTouch.zip
    3 KB · Views: 223

Semen Matusovskiy

Well-Known Member
Licensed User
1) I don't see Sub menu_ItemClicked (Tag As Object) in Main.

2) A behaviour is really strange. But a problem is in wrong code.

From one side I see 'Custom View class . Means you added exactly Custom View.
But there is no DesignerCreateView and you obviously use a module as Standard Class. Means there is no mBase etc.
Reconstruct and then it will be possible to discuss.
 
Last edited:
Upvote 0

cxbs

Active Member
Licensed User
Longtime User
1) I don't see Sub menu_ItemClicked (Tag As Object) in Main.

2) A behaviour is really strange. But a problem is in wrong code.

From one side I see 'Custom View class . Means you added exactly Custom View.
But there is no DesignerCreateView and you obviously use a module as Standard Class. Means there is no mBase etc.
Reconstruct and then it will be possible to discuss.

Hello, women matusovskiy
Thank you for your reply,
I simplified the code for easy viewing,
The problem is that click or touch events cannot be received,
I know that click and touch events cannot appear at the same time, so I only keep touch events,
But I still can't receive it. I don't know what caused it.
The above English is from translation software
 
Upvote 0
Top