Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private notePnl As B4XView
Private BBCodeView1 As BBCodeView 'in designer fill parent, color transparent, no border
Private TextEngine1 As BCTextEngine
End Sub
Public Sub Initialize
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
TextEngine1.Initialize(Root)
notePnl = xui.CreatePanel("note")
notePnl.Visible = False
Root.AddView(notePnl, 100, 100, 400, 600)
notePnl.LoadLayout("bbcv") 'a generic view that fills the panel
BBCodeView1.TextEngine = TextEngine1
BBCodeView1.sv.ScrollViewInnerPanel.Color = xui.Color_Yellow
BBCodeView1.sv.SetColorAndBorder(xui.Color_Transparent, 1, xui.Color_RGB(200, 200, 200), 3)
BBCodeView1.mBase.Visible = False
#If B4J
BBCodeView1.sv.As(ScrollPane).SetVScrollVisibility("NEVER") 'only needed for B4J
#End If
Dim padding As B4XRect
padding.Initialize(4, 4, 4, 4)
BBCodeView1.Padding = padding 'part of this BBCodeView1 independent of text contents
Sleep(2000) 'popup note after 2 seconds for testing
popupNote($"This is the easiest part${CRLF}${CRLF}[Alignment=Center](touch here to close note)[/Alignment]"$)
End Sub
Private Sub popupNote(s As String)
BBCodeView1.text = "[TextSize=18][Color=Blue]" & s & "[/Color][/TextSize]"
'adjust note panel To txt height
notePnl.Height = BBCodeView1.Paragraph.Height / TextEngine1.mScale + BBCodeView1.Padding.Top + 2 * BBCodeView1.Padding.Bottom
BBCodeView1.mBase.Visible = True
notePnl.Visible = True
wait for Note_Closed
'repeat for testing
Sleep(2000) 'popup note after 2 seconds for testing
popupNote($"This is the easiest part${CRLF}${CRLF}[Alignment=Center](touch here to close note)[/Alignment]"$)
End Sub
#If B4J
Private Sub note_MouseClicked(Ev As MouseEvent)
notePnl.Visible = False
CallSubDelayed(Me, "Note_Closed")
End Sub
#Else if B4A
Private Sub note_Click
notePnl.Visible = False
CallSubDelayed(Me, "Note_Closed")
End Sub
#End If