Italian Canvas (o panel) scrollabile

Prova così, purtroppo sono fuori e non posso fare prove.
B4X: Copy
Dim P as Pane
P.Initialize("")
ScrollPane.InnerNode=P

B4XCanvas.Initialixe(P)
 
Allora, l'errore non lo da più, ma non scrive nulla nel B4XCanvas.
Posto il codice
B4X: Copy
    Dim P As Pane
    Dim    fnt As Font
    Dim xfntTitle As B4XFont
    P.Initialize("")
    ScrollPane.InnerNode = p
    B4XCanvas.Initialize(P)
    fnt = fx.CreateFont("Arial", 14, False, False)
    xfntTitle = xui.CreateFont(fnt, 14)
    Dim righe() As String = Regex.Split(CRLF, txtRighe.text)
    Dim y As Int = 40
    For Each riga As String In righe
        B4XCanvas.DrawText(riga, 20, y, xfntTitle, xui.Color_Black, "LEFT")
        y = y+40
    Next
txtRighe è una textArea popolata di numerose righe.
Prima, con il solo pane scriveva ma non era scrollabile, ora non scrive più
 
Invalidate in B4XCanvas lo hai messo?
 
yes
 
Attached a small test project.

The code:
This line is special but needed:
scpTest.LoadLayout("Dummy", 1000, 1000) 'Dummy is an empty layout, it is needed to get the internal Pane, and it sets the inner Pane dimensions
B4X: Copy
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
    
    #If B4J
    Private scpTest As ScrollPane   
    #End If
    Private xpnlText As B4XView
    Private xcvsTest As B4XCanvas
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")   
    'Dummy is an empty layout, it is needed to get the internal Pane, and it sets the inner Pane dimensions
    scpTest.LoadLayout("Dummy", 1000, 1000) 
    MainForm.Show
    
    InitCanvas
    DrawText
End Sub

Private Sub InitCanvas
    #If B4J
    xpnlText = scpTest.InnerNode
    xcvsTest.Initialize(xpnlText)
    #End If
End Sub

Private Sub DrawText
    xcvsTest.DrawText("Text 1", 10, 20, xui.CreateDefaultFont(12), xui.Color_Black, "LEFT")
    xcvsTest.DrawText("Text 2", 10, 40, xui.CreateDefaultFont(12), xui.Color_Black, "LEFT")
    xcvsTest.DrawText("Text 3", 10, 60, xui.CreateDefaultFont(12), xui.Color_Black, "LEFT")
    xcvsTest.DrawText("Text 4", 10, 80, xui.CreateDefaultFont(12), xui.Color_Black, "LEFT")
    xcvsTest.DrawText("Text 5", 10, 980, xui.CreateDefaultFont(12), xui.Color_Black, "LEFT")
    xcvsTest.DrawText("Text 6", 990, 980, xui.CreateDefaultFont(12), xui.Color_Black, "RIGHT")
End Sub

The image:

1617184803693.png
 

Attachments

Funziona...
...certo che inserire un layout vuoto non ci sarei proprio arrivato.
Grazie
 
Back
Top