B4J Question [Banano] How to set properties of widget like SKLabel etc...

Toky Olivier

Active Member
Licensed User
Longtime User
Hello all,
It's a while I have not coded with B4X now, I have one project I would like to make with Banano. But I stuck on a basic thing. I tried to look on the forum but I cannot find.
How to set properties of Banano customview ?

I set like here but it doesn't work (It's the template Banano PWA):
B4X:
Sub MenuList_Click (returnName As String)
    SKTools.ShowToast("Clicked on " & returnName & "!", "info", 3000, True)
    ' here we can load the layout of the menu item we clicked
    Select Case returnName
        Case "page1"
            MainPageHolder.Element.Empty
            MainPageHolder.Element.LoadLayout("WelcomePageLayout")
          
            '===> I set like this text or image but it doesn't work for me :(
            SKLabel1.Text = "One Text"
            SKImage1.Src = "./assets/safari.png"
    End Select
    ' and close the menu, if not always open
    If MainSidebar.AlwaysOpen = False Then
        MainSidebar.Close
    End If 
End Sub

It's doesn't work for me. .
2022-03-03 08_55_07-BANano Skeleton.png


Thank you, It's a shame for me, it's a basic things... ;-(

Regards,
Toky
 
Last edited:
Solution
It took some searching as they are actually in the WelcomePageLayout, not the WelcomeModalLayout ;)

The reason it doesn't work is because the AutoID/Name was checked on those two components. (it is checked by default as most of the time these type of object do not need to changed or accessed in code).

When AutoID/Name is checked, the BANano transpiler will give them a random name (e.g. aedfgthj) instead of SKLabel1.

1646294125425.png


So, if you want to access these components in your code, just uncheck this box.

Made these changes and after clicking on 'Welcome page' in the side menu we'll get:

1646294301328.png


I see if I can add an extra chapter 'Troubleshooting' in the next version of the booklet. I was already...

Toky Olivier

Active Member
Licensed User
Longtime User
Yes, i set it to change only when the side menu item is clicked. I know it works if I do it in the abstract designer but it's not I want to do.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
It took some searching as they are actually in the WelcomePageLayout, not the WelcomeModalLayout ;)

The reason it doesn't work is because the AutoID/Name was checked on those two components. (it is checked by default as most of the time these type of object do not need to changed or accessed in code).

When AutoID/Name is checked, the BANano transpiler will give them a random name (e.g. aedfgthj) instead of SKLabel1.

1646294125425.png


So, if you want to access these components in your code, just uncheck this box.

Made these changes and after clicking on 'Welcome page' in the side menu we'll get:

1646294301328.png


I see if I can add an extra chapter 'Troubleshooting' in the next version of the booklet. I was already planning an extra chapter specific on BANanoSkeleton anyway.

Alwaysbusy
 
Upvote 1
Solution

Toky Olivier

Active Member
Licensed User
Longtime User
When AutoID/Name is checked, the BANano transpiler will give them a random name (e.g. aedfgthj) instead of SKLabel1
Ah, Okay I see. With buttons and textboxes for example, there is no AutoID/Name property and it works.
I tested it and it works now.

But I think that even if the transpiler give a random name, SKLabel1 should point the random name and setting SKLabel1.propertyName should work.
 
Upvote 0
Top