' globals
Private Page As ABMPage ' owner ABMPage of this class
Private Caller As Object ' Class that holds the ABMPage
Private Name as String
Private Cont as ABMContainer
...
Public Sub Initialize(ObjectName As String, TargetCaller As Object, TargetPage As ABMPage) As ABMContainer
Page = TargetPage
Caller = TargetCaller
Name = ObjectName
cont.Initialize(Page, "Cont" & Name, "")
cont.AddRowsM(3, True,0,0,"").AddCellsOS(1,2,2,2,10,5,5,"").AddCellsOS(1,0,0,0,12,5,5, "ccenter")
cont.AddRowsM(1, True,0,0,"").AddCellsOS(1,2,2,2,10,10,10,"")
cont.AddRows(1,True,"").AddCells12(1,"")
cont.BuildGrid
Dim inpBarcode As ABMInput
inpBarcode.Initialize(Page, Name & "inpBarcode", ABM.INPUT_TEXT, "barcode", False, "onetwo")
cont.Cell(RowIndex,1).AddComponent(inpBarcode)
...
cont.EventHandler = Me '<----------------- We want all events that happen to this container (and it's children) to be handled by this class, not the main page
Return cont
End Sub
' this class has it's own ParseEvent method, and is called by the Main's ParseEvent (the else CallSubDelayed2 if Caller <> Me)
public Sub ParseEvent(params As Map)
Dim eventName As String = params.Get("eventname")
Dim eventParams() As String = Regex.Split(",",params.Get("eventparams"))
If eventName.ToLowerCase.StartsWith(Name.ToLowerCase) Then
eventName = eventName.SubString(Name.Length)
End If
If SubExists(Me, eventName) Then
params.Remove("eventname")
params.Remove("eventparams")
Select Case params.Size
Case 0
CallSub(Me, eventName)
Case 1
CallSub2(Me, eventName, params.Get(eventParams(0)))
Case 2
If params.get(eventParams(0)) = "abmistable" Then
Dim PassedTables As List = ABM.ProcessTablesFromTargetName(params.get(eventParams(1)))
CallSub2(Me, eventName, PassedTables)
Else
CallSub3(Me, eventName, params.Get(eventParams(0)), params.Get(eventParams(1)))
End If
Case Else
' cannot be called directly, to many param
CallSub2(Me, eventName, params)
End Select
End If
End Sub
' handling the event here, in the Class itself, not in the main
Sub inpBarCode_LostFocus()
Dim inpBarcode As ABMInput = cont.Component(Name & "inpBarcode")
' do something on the Main Page with it
CallSub2(Caller, "CONT" & Name & "_DoSomething", inpBarcode.Text)
End Sub