B4J Question Change menubar JSON selection

ThRuST

Well-Known Member
Licensed User
Longtime User
I'm using Derez menu designer to make a JSON menu. There's a menu to change colors and a few selections. How can I access these JSON selections from code? If one is true I want to set the others to false from code.

In the event sub for the menu I tried to access the menu items by but there's no access to individual items.

B4X:
Dim mi2 As CheckMenuItem = Sender

Cheers
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm using Derez menu designer to make a JSON menu.
It doesn't really matter how you create the menu.

B4X:
Sub MenuBar1_SelectedChange (Selected As Boolean)
   If Selected Then
       Dim jo As JavaObject = Sender
       Dim parent As Menu = jo.RunMethod("getParentMenu", Null) 'will be available in the next update of B4J
       For Each mi As MenuItem In parent.MenuItems
           If mi Is CheckMenuItem And mi <> Sender Then
               Dim cmi As CheckMenuItem = mi
               cmi.Selected = False
           End If
       Next
   End If
End Sub
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Nice solution it will keep me busy all new years eve. I was hoping for a simpler solution just to access each selection individually even though your code is efficient and great. There's perhaps other ways since it will be available in the next update :)
 
Upvote 0
Top