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
 

stevel05

Expert
Licensed User
Longtime User
Can you show us how you have created the button, then we might be able to help.
 
Upvote 0

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
Where does the value of iconhex come from? Is it really a string?
 
Last edited:
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

stevel05

Expert
Licensed User
Longtime User
Are you changing the size of the button in your code?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Are you loading any css files into the project that may overwrite the font setting?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Try removing them and see if it makes a difference to the button.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Also does it do the same in Release mode?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Last edited:
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