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
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