B4J Question FontAwesome at runtime

micro

Well-Known Member
Licensed User
Longtime User
Hi to all
If I create a button at runtime and add FontAwesome text and icon when i move or click on the button the icon is no longer displayed correctly.
Why?
Thanks
 

micro

Well-Known Member
Licensed User
Longtime User
Can you show us how you have created the button, then we might be able to help.
B4X:
Dim bt As Button
bt.Initialize("btmainarc")
bt.Font = fx.CreateFontAwesome(14)
'In iconhex i have the value
dim s As String =  iconhex.Replace("0x", "")
bt.Text = "Text " &  Chr(Bit.ParseInt(s, 16))

The Text and the icon is regularly displayed.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
This works for me:
B4X:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    MainForm.Show
    Dim bt As Button
    Dim iconHex As String = "0xF0AB"
    bt.Initialize("btmainarc")
    bt.Font = fx.CreateFontAwesome(14)
'    'In iconhex i have the value
'    bt.Text = "Text " &  Chr(iconHex)
    'In iconhex i have the value
    Dim s As String =  iconHex.Replace("0x", "")
    Log(s)
    bt.Text = "Text " &  Chr(Bit.ParseInt(s, 16))
   
   
    MainForm.RootPane.AddNode(bt,50,50,150,50)
End Sub

Are you changing the text of the button anywhere?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
That example is clickable, the font doesn't change. There must be another reason that it does in your app.
 
Upvote 0

micro

Well-Known Member
Licensed User
Longtime User
button.PNG
button_mouse_on.PNG
 
Upvote 0

micro

Well-Known Member
Licensed User
Longtime User
it is true stevel05
is CCSUTILS the problem, if I eliminate this
B4X:
CSSUtils.SetStyleProperty(bt, "-fx-font-weight", "bold")
work fine.
Thanks
 
Last edited:
Upvote 0
Top