iOS Question B4i Issue with BarButton_Click Event

mmieher

Active Member
Licensed User
Using these subs I found in the forum:
B4X:
Private Sub BarButton_Click
    Dim b As Button = Sender
    Log("Toolbar Click Tag = " & b.Tag)
    mnu.MenuClick("Menu")
End Sub

Public Sub CreateFABarIcon(text As String, tag As Object) As BarButton
    Dim bb As BarButton
    Dim b As Button
    b.InitializeCustom("BarButton", Colors.White, Colors.RGB(16,116,74))
    b.CustomLabel.Font = Font.CreateNew2("FontAwesome", 32)
    b.Text = text
    b.Tag = tag
    b.SetLayoutAnimated(0, 1, 0, 0, 24, 24)
    bb.InitializeCustom(b)
    Return bb
End Sub

Private Sub CreateFABarImg(sFile As String, tag As Object) As BarButton
    Dim bb As BarButton
    Dim b As ImageView
    b.Initialize("img")
    b.Bitmap=LoadBitmap(File.DirAssets,sFile)
    b.Tag = tag
    b.SetLayoutAnimated(0, 1, 0, 0, 24, 24)
    bb.InitializeCustom(b)
    Return bb
End Sub
With this, BarButton_Click is fired.
Dim lbHamburger As BarButton = CreateFABarIcon(Chr(0xF0C9),"Menu")

But with this, it does not? I do not see why there is a difference.
Dim lbHamburger As BarButton = CreateFABarImg("hamburger.png","Menu")
 

mmieher

Active Member
Licensed User
Thanks, Erel. I stripped my big project down to a little one. Also note that the SetLayoutAnimated on the BarButton is not working. Trying to position it on the left.
 

Attachments

Jamie8763

Active Member
Licensed User
Replacing the
B4X:
b.CustomLabel.Font ....
with this
B4X:
b.CustomLabel.Font = Font.CreateFontAwesome(32)
seem to work great and I can see the hamburger tag events in the console
 
Top