iOS Question Getting reference to the Rootpanel of current page

Cadenzo

Active Member
Licensed User
Longtime User
Some iOS dialogs like ActionSheet need a reference to the Rootpanel of current page. I have this sub in a Dialogs class and would like to do without the first parameter "pnl As Panel". Is there another way to get the Rootpanel of the page from where this function is called?
B4X:
Sub InputListDialog(pnl As Panel, items As List, cancelItem As String, destructiveItem As String, titel As String) As ResumableSub
    Dim acSheet As ActionSheet
    acSheet.Initialize("sheet", titel, cancelItem, destructiveItem, items)
    acSheet.Show(pnl)
   
    Wait For sheet_Click (value As String)
    Dim iRes As Int = -1
    If value = cancelItem Then
        iRes = -1
    else if value = destructiveItem Then
        iRes = -2
    Else
        For i = 0 To items.Size - 1
            If items.Get(i) = value Then iRes = i
        Next
    End If
    Return iRes
End Sub
 

Semen Matusovskiy

Well-Known Member
Licensed User
For NavigationController only.

You can retrieve visible page using
B4X:
Dim no As NativeObject = App.KeyController        
Private VisiblePage As Page
VisiblePage = no.RunMethod ("visibleViewController", Null)

Then you can use VisiblePage.RootPanel
 
Upvote 0

Cadenzo

Active Member
Licensed User
Longtime User
The correct solution is to use B4XDialog with B4XListTemplate.
OK, but the B4XListTemplate don't use the ActionSheed. It is a good solution for cross platform, but in some situations I want the iOS native view with "DestructiveItem". So I see, that in XUI Views only the ComboBox uses ActionSheed with iOS, right? To keep it more equal with Android, I don't want to pass the Panel as parameter. Can I do it like that, with xui.CreatePanel?

B4X:
 Dim pnl as Panel = xui.CreatePanel("mBase")
 Dim acSheet As ActionSheet
 acSheet.Initialize("sheet", titel, cancelItem, destructiveItem, items)
 acSheet.Show(pnl)
 
Upvote 0
Top