B4J Question Save/Load Menubar Structure

ThRuST

Well-Known Member
Licensed User
Longtime User
This question concerns B4J. Can someone please provide a simple working example how to save and load a Menubar with menuitems structure. The menu is in this case created with Scene builder 2.
I have little knowledge about the manual way with JSON and save as MAP that's why I use scene builder as a way to visually create the menu. But since I need a good way to save and load it I post here.
Magic wizards of B4J community please help :)

Best regards,
Roger Lindfors
 

ThRuST

Well-Known Member
Licensed User
Longtime User
Don't use scene builder. You should use the internal designer.

Do you need to change the menu structure at runtime?

Yes that would be the best. Actually what I want is to handle the menubar manually so I can use the internal designer instead of Scene builder :)
I found an exampe in the forum that I can play around with, but how to save and load the generated structure? Must it be saved as a MAP?
What is a MAP format? Thank you Erel. Btw dark theme in editor looks great, even better than visual studio I love B4X concept it's the best :)

Dim ports As Menu
ports.Initialize("Ports", "")
Dim FileMenu As Menu
FileMenu.Initialize("FileMenu", "")
MenuBar.Menus.Add(FileMenu)
FileMenu.MenuItems.Add(ports)
For Each m As String In Array As String("a", "b", "c")
Dim mm As MenuItem
mm.Initialize(m, "mm")
ports.MenuItems.Add(mm)
Next
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
How to save/load and delete items from the menubar structure manually? anyone?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Extremely useful indeed, but how to save and load that structure into a menubar manually? It comes back to that MAP format again as I have not found a good explanation about how the MAP format works. Source code examples for how to Save and Load into a menubar is highly appreciated.
Btw, why not implement that editor into the editor GUI? Ask the author and we'll be blessed (again) :) Thanks
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Somewhere in this forum you said a menubar structure must be saved as a map and not as a textfile. I guess it will be less confusing if you provide a simple example how to actually SAVE and LOAD the JSON formatted menubar structure into the menubar. After all it makes more sense to study someones code to understand how it works. I also asked how to remove a menu/menuitem from runtime if that's possible please share some examples for us all to study. Thanks
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
The menu structure (JSon string) is part of the menu properties in the designer.
When you add a menu to your layout, it comes with a default menu structure to serve as example.
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
How to read a Json string into the menubar? I guess many will be thanksful that I asked this question :)
 
Upvote 0
Top