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
 
Can you show us how you have created the button, then we might be able to help.
Code:
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
This works for me:
Code:
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
That example is clickable, the font doesn't change. There must be another reason that it does in your app.
 
Upvote 0
button.PNG
button_mouse_on.PNG
 
Upvote 0
it is true stevel05
is CCSUTILS the problem, if I eliminate this
Code:
CSSUtils.SetStyleProperty(bt, "-fx-font-weight", "bold")
work fine.
Thanks
 
Last edited:
Upvote 0
Back
Top