I've had no problem making csbuilder clickable text work in b4a, where you specify the name of the event handler in csbuilder. For b4i it looks like the handler for the control that hosts the cs content is supposed to raise a "LinkClick" event. I've tried this, and looked at examples here, and just can't make it work.
I created a new empty b4i B4xPages project, then replaced the hello world with this:
B4X:
Private Sub Button1_Click
Dim cs As CSBuilder
cs.Initialize.Append("This is ").Link("mylink").Append("a clickable bit of text.").PopAll
Dim lbl As Label
lbl.Initialize("lblEvent")
lbl.AttributedText=cs
Root.AddView(lbl,200,200,300,200)
End Sub
Private Sub lblEvent_LinkClick(URL As String)
Log("URL = " & URL)
End Sub
When you click the button the label is loaded onto the screen, and the link part of it is underlined as you would expect a link to be. But touch the link all you want I can't get an event to fire. I'm missing something obvious here.
Ah textview only, that's pretty clear in examples. I looked right past it when I saw that labels have an attributedtext property. So I switch label to textview and cs linkclick fires. Textview though isn't taking on the font I was assigning the way that a label was.
B4X:
Dim lbl as Label
lbl.Initialize("clickme")
lbl.Font=xui.CreateDefaultBoldFont(20) 'label uses font as expected
Dim txt as TextView
txt.Initialize("clickme")
txt.Font=xui.CreateDefaultBoldFont(20) 'textview ignores font
txt.Font=Font.CreateNewBold(20) 'didn't work either
I'll keep trying things, looks like there are lots of ways to generate fonts. I was using xui because I was sharing a font subroutine between b4i and b4a
Oh nevermind, of course font in csbuilder is overriding textview font. I have too many things going on right now. Thanks for mention of BCTextEngine I'll take a look.