xulihang Well-Known Member Licensed User Longtime User Mar 17, 2020 #1 I am trying to use BBLabel to show rich text. I can add them by using the designer. But I need to add them by code. I didn't figure out how to do this. I can add a pane which contains a BBLabel, but I can't get it by GetNode method. B4X: Copy Dim pane As Pane pane.Initialize("") pane.LoadLayout("bblabel") MainForm.RootPane.AddNode(pane,10,10,100,100) Dim BBLabel1 As BBLabel=MainForm.RootPane.GetNode(0) 'error type not match
I am trying to use BBLabel to show rich text. I can add them by using the designer. But I need to add them by code. I didn't figure out how to do this. I can add a pane which contains a BBLabel, but I can't get it by GetNode method. B4X: Copy Dim pane As Pane pane.Initialize("") pane.LoadLayout("bblabel") MainForm.RootPane.AddNode(pane,10,10,100,100) Dim BBLabel1 As BBLabel=MainForm.RootPane.GetNode(0) 'error type not match
xulihang Well-Known Member Licensed User Longtime User Mar 17, 2020 #2 I come up with this after some study of the source code. B4X: Copy Dim pane As Pane pane.Initialize("") pane.LoadLayout("bblabel") Dim TextEngine As BCTextEngine TextEngine.Initialize(pane) MainForm.RootPane.AddNode(pane,10,10,100,100) Dim n As Pane=pane.GetNode(0) Dim BBLabel1 As BBLabel=n.Tag Upvote 0
I come up with this after some study of the source code. B4X: Copy Dim pane As Pane pane.Initialize("") pane.LoadLayout("bblabel") Dim TextEngine As BCTextEngine TextEngine.Initialize(pane) MainForm.RootPane.AddNode(pane,10,10,100,100) Dim n As Pane=pane.GetNode(0) Dim BBLabel1 As BBLabel=n.Tag
Erel B4X founder Staff member Licensed User Longtime User Mar 17, 2020 #3 Tip: - No reason to use the Pane type. B4XView is better. - Never load a layout to a zero sized container . Code: Copy Dim panel As B4XView = xui.CreatePanel("") MainForm.RootPane.AddNode(panel,10,10,100,100) panel.LoadLayout("bblabel") TextEngine.Initialize(pane) If BBLabel1 is a global variable then it will hold a reference to the BBLabel that was created. Otherwise: Code: Copy Dim BBLabel1 As BBLabel = panel.GetView(0).Tag Upvote 0
Tip: - No reason to use the Pane type. B4XView is better. - Never load a layout to a zero sized container . Code: Copy Dim panel As B4XView = xui.CreatePanel("") MainForm.RootPane.AddNode(panel,10,10,100,100) panel.LoadLayout("bblabel") TextEngine.Initialize(pane) If BBLabel1 is a global variable then it will hold a reference to the BBLabel that was created. Otherwise: Code: Copy Dim BBLabel1 As BBLabel = panel.GetView(0).Tag