iOS Question Callsubdelayed not working in TableView _SelectedChanged event

Paulo Barros

Member
Licensed User
Longtime User
Hi!
I am surely doing something wrong, so i hope someone will be so kind to explain me why it is not working.
I use this in a code module:

Active page is: Page1000

B4X:
Private Sub LstMenu_SelectedChanged (SectionIndex As Int, Cell As TableCell)
Dim tlst As TableView
Dim lst As List
tlst=Sender
Dim tcs As TableCell
lst = tlst.GetItems(SectionIndex)
For Indice=0 To lst.Size -1
tcs=lst.Get(Indice)
If tcs.Text.ToString=Cell.Text.ToString Then
Exit
End If
Next
Page1000.ResignFocus
If SubExists(Fixi0050,"ShowActivity0050",1) Then
CallSubDelayed2(Fixi0050,"ShowActivity0050",Indice)
'Fixi0050.ShowActivity0050
End If
End Sub

Tableview is initialized in the same module and result is that ShowActivity0050 is not firing
If i made a direct call like the above commented "Fixi0050.ShowActivity0050" then i get then sub working, but the related sub _Resize of code module Fixi0050 doesn't work as any other private sub.
Fixi0050.ShowActivity0050 is already declared as Public.

If i put the calling code in a normal sub like:
B4X:
Private Sub Lbl_Click
Indice = 3
Page1000.ResignFocus
If SubExists(Fixi0050,"ShowActivity0050",1) Then
CallSubDelayed2(Fixi0050,"ShowActivity0050",Indice)
'Fixi0050.ShowActivity0050
End If
End Sub

it works fine....

It seems that Tableview takes a specific kind of ownership when calling sub.
Thank you all for the attention.
 
Last edited:

Paulo Barros

Member
Licensed User
Longtime User
Sorry, _SelectedChanged works
I still have the problem and i really don't know how to fix it.
To be more clear i prepared an example and it works fine, so i have to assume that there's no problem with B4I software (i was already sure on that!)
Atached i have the working example that make me sure i mistake something in my code.

B4X:
#Region  Project Attributes
    #ApplicationLabel: Example
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page

    Private tv As TableView
   
    Private lst As List
End Sub

Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)

End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
    CallSubDelayed(Me,"LoadTableview")
End Sub

Private Sub Application_Background
   
End Sub

Private Sub LoadTableview
    tv.Initialize("Tv",True)

    lst.Initialize
    lst.Add("Item1")
    lst.Add("Item2")
    lst.Add("Item3")
    lst.Add("Item4")
    lst.Add("Item5")
    lst.Add("Item6")
    For i=0 To lst.Size -1
        Dim at As AttributedString
        at.Initialize(lst.Get(i),Font.CreateNew(21),Colors.Black)
        Dim tc As TableCell = tv.AddSingleLine("")
        tc.Text = at
    Next
    Page1.RootPanel.AddView(tv,0,0,100%x,100%y)
End Sub

Private Sub tv_SelectedChanged (SectionIndex As Int, Cell As TableCell)
    Dim tv1 As TableView
    Dim tc As TableCell
    Dim celllst As List
    tv1=Sender
    celllst = tv1.GetItems(SectionIndex)
    For i=0 To celllst.Size -1
        tc=celllst.Get(i)
        If tc.Text.ToString=Cell.Text.ToString Then
            Exit
        End If
    Next
    Dim str As String=lst.Get(i)
    'Msgbox(str,"Selected")
    Page1.ResignFocus
    'Deeper.ShowDeeper(str)
    CallSubDelayed2(Deeper,"ShowDeeper",str)
   
End Sub

In my code no sub of the second page is working instead the showactivity ones when it is directed called.
Here the second page code to prove that also private subs are working

B4X:
'Code module:  Named Deeper

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Private Page2 As Page
    Private lbl As Label
End Sub

public Sub ShowDeeper (textstr As String)
    Page2.Initialize("Page2")
    Page2.RootPanel.Color = Colors.White
    Main.NavControl.ShowPage2(Page2,True)
    lbl.Initialize("lbl")

    Page2.RootPanel.AddView(lbl,50,50,200,40)
    lbl.TextColor = Colors.Black
    lbl.Text= textstr
End Sub

Private Sub Page2_Resize (Width As Int, Height As Int)
    lbl.TextColor=Colors.Blue
End Sub

Private Sub lbl_Click
    Msgbox(lbl.Text,"Info")
End Sub
 
Upvote 0

Paulo Barros

Member
Licensed User
Longtime User
Hi !
I get it!
In debug mode was not working bat it was in realease mode.
Thanks to those they saw the tread and figured out a solution that could help me.
Code in the second post maybe can be useful to those they are approacing TableView for first time.

See you soon
 
Upvote 0
Top