iOS Question A canvas in B4XPages

Aldo's

Active Member
Licensed User
Hi, I have a B4 XPages project. I didn't understand how to create a B4XCanvas on a sub page. In Designer it doesn't let me add it. Can you help me?
 

klaus

Expert
Licensed User
Longtime User
You need to add a Panel in the Designer and declare it as a B4XView. Then in the code link the B4XCanvas to the Panel.
Something like this:
B4X:
Private xpnlGraph As B4XView
Private xcvsGraph As B4XCanvas
And in Sub B4XPage_Created:
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    xcvsGraph.Initialize(xpnlGraph)
 
Upvote 0

Aldo's

Active Member
Licensed User
I try and then I tell you
 
Upvote 0

Aldo's

Active Member
Licensed User
This is my code:
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private pnlGraph As B4XView
    Private xcvsGraph As B4XCanvas
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
    
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("CantoLO")
    B4XPages.SetTitle(Me, Main.sCanto)
    xcvsGraph.Initialize(pnlGraph)
    xcvsGraph.DrawText("prova di scrittura con DrawText", 20, 50, Font.DEFAULT, xui.Color_Blue, "LEFT")
End Sub
opens the new page but does not execute the DrawText.
 
Upvote 0

Aldo's

Active Member
Licensed User
it works. Thank you very much
 
Upvote 0

Aldo's

Active Member
Licensed User
I added a small chapter in the B4X Graphics booklet to highlight it.
It is only needed in B4A or XUI.
I think it is also necessary in B4I ...
it didn't work before.
 
Upvote 0

Aldo's

Active Member
Licensed User
Thanks for all your answers.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I think it is also necessary in B4I ...
Just to clarify.
Perhaps I misread your post.
In pure B4i, with a B4i Canvas, it is needed with cvsGraph.Refresh.
In B4i, with a B4XCanvas, it is needed with cvsGraph.Invalidate.
 
Upvote 0
Top