Can a class module to create an event? Example of a User View "cbButton":
Class module "cbButton":
Activity module:
Greetings
Petrus
Class module "cbButton":
B4X:
Sub Class_Globals
Dim Control As Object
Private Panel1 As Panel
Private Label1 As Label
End Sub
'Initializes the object. You can add parameters to this method if needed.
Sub Initialize()
Panel1.Initialize("Panel1")
Control = Panel1
Panel1.Color = Colors.Magenta
Label1.Initialize("")
Label1.TextColor = Colors.Black
Label1.TextSize = 20
Label1.Text = "Test"
Label1.Gravity = Gravity.CENTER_HORIZONTAL + Gravity.CENTER_VERTICAL
Panel1.AddView(Label1, 0, 0, 10,10)
End Sub
Public Sub SetLayout(Left As Int, Top As Int, Width As Int, Height As Int)
Panel1.SetLayout(Left, Top, Width, Height)
Label1.SetLayout(0,0,Width, Height)
End Sub
Sub Panel1_Click()
'and now?
'...
End Sub
Activity module:
B4X:
Sub Globals
Dim CbButton1 As cbButton
End Sub
Sub Activity_Create(FirstTime As Boolean)
CbButton1.Initialize()
Activity.AddView(CbButton1.Control, 10,10,100,50)
CbButton1.SetLayout(100, 100, 200, 100)
End Sub
Sub CbButton1_Click()
'????
End Sub
Greetings
Petrus