ThRuST Well-Known Member Licensed User Longtime User Nov 15, 2016 #1 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
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
Erel B4X founder Staff member Licensed User Longtime User Nov 15, 2016 #2 Don't use scene builder. You should use the internal designer. Do you need to change the menu structure at runtime? Upvote 0
Don't use scene builder. You should use the internal designer. Do you need to change the menu structure at runtime?
ThRuST Well-Known Member Licensed User Longtime User Nov 15, 2016 #3 Erel said: Don't use scene builder. You should use the internal designer. Do you need to change the menu structure at runtime? Click to expand... 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
Erel said: Don't use scene builder. You should use the internal designer. Do you need to change the menu structure at runtime? Click to expand... 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
ThRuST Well-Known Member Licensed User Longtime User Nov 15, 2016 #4 How to save/load and delete items from the menubar structure manually? anyone? Upvote 0
ThRuST Well-Known Member Licensed User Longtime User Nov 15, 2016 #5 Btw what's wrong with Scene builder 2? Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Nov 16, 2016 #6 ThRuST said: Btw what's wrong with Scene builder 2? Click to expand... B4J is optimized to work with the internal designer. The support for scene builder is only kept to support old projects. Don't use it with new projects. You can use this tool to create the JSON string for the menu: https://www.b4x.com/android/forum/threads/menu-designer.56853/#content Upvote 0
ThRuST said: Btw what's wrong with Scene builder 2? Click to expand... B4J is optimized to work with the internal designer. The support for scene builder is only kept to support old projects. Don't use it with new projects. You can use this tool to create the JSON string for the menu: https://www.b4x.com/android/forum/threads/menu-designer.56853/#content
ThRuST Well-Known Member Licensed User Longtime User Nov 16, 2016 #7 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
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
Erel B4X founder Staff member Licensed User Longtime User Nov 16, 2016 #8 I'm not sure why you call it MAP format. It is a JSON format. It is worth learning JSON. It is very simple and wildly used. It is not possible to replace the JSON string at runtime. You will need to either use multiple menus and show the correct one each time or manually build the menu items. Upvote 0
I'm not sure why you call it MAP format. It is a JSON format. It is worth learning JSON. It is very simple and wildly used. It is not possible to replace the JSON string at runtime. You will need to either use multiple menus and show the correct one each time or manually build the menu items.
ThRuST Well-Known Member Licensed User Longtime User Nov 16, 2016 #9 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
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
Erel B4X founder Staff member Licensed User Longtime User Nov 17, 2016 #10 ThRuST said: 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 Click to expand... As I already wrote, it is not possible to replace the JSON string at runtime. Upvote 0
ThRuST said: 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 Click to expand... As I already wrote, it is not possible to replace the JSON string at runtime.
Cableguy Expert Licensed User Longtime User Nov 17, 2016 #11 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
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.
ThRuST Well-Known Member Licensed User Longtime User Nov 17, 2016 #12 How to read a Json string into the menubar? I guess many will be thanksful that I asked this question Upvote 0
How to read a Json string into the menubar? I guess many will be thanksful that I asked this question
I inakigarm Well-Known Member Licensed User Longtime User Nov 17, 2016 #13 Have you seen this post: https://www.b4x.com/android/forum/threads/designer-menu-items.56602/ There're examples on it Upvote 0
Have you seen this post: https://www.b4x.com/android/forum/threads/designer-menu-items.56602/ There're examples on it
ThRuST Well-Known Member Licensed User Longtime User Nov 17, 2016 #14 Thanks I'll check it out. Upvote 0