This seems to work OK:
In the B4XPage:
Sub Get_PageClass() As Object
Return Me
End Sub
Sub Get_PageRoot() As B4XView
Return Root
End Sub
In the normal class:
Sub GetRootAndClass(strPageID As String) As ResumableSub
Log("GetRootAndClass, strPageID: " & strPageID)
moRoot = CallSub(B4XPages.GetPage(strPageID), "Get_PageRoot")
mCallBack = CallSub(B4XPages.GetPage(strPageID), "Get_PageClass")
Return True
End Sub
And called in this class like this:
Dim rs As ResumableSub = GetRootAndClass("Page" & miButtonStartIndex)
Wait For (rs) Complete (bDone As Boolean)
Although my code logs show I get the right page root (from the Tag of the root), I still have problems (layout not showing) and not sure the layout was added to the right page, looking at my log and B4XPages.GetManager.LogEvents (set to True):
SetMenuBar, miButtonStartIndex: 8, iMenuButtonEndIndex: 14
SetMenuBar, iHighlightedButton: -1
*** page0: B4XPage_Disappear [mainpage, page0]
*** page8: B4XPage_Appear [mainpage, page0] <<<<<<<<< I expected this to be page8
GetRootAndClass, strPageID: Page8
SetMenuBar, bDone: true
SetMenuBar, moRoot.Tag: 8
>>> B4XPage_Appear: page8 appeared
I think this might need another question as it is a different problem.
RBS