This is my first attempt at a menu, starting with the Tutorial and the default text when a menu is added I have produced the code below. I thought that this is so simple it could not fail, I was wrong.
I sorted it out with the code below. I will have another look at setting the EventName property next year.
There must be a better way of designing menus. Arcane JSON strings or convoluted subs calling subs? [WishList item]
B4X:
Sub MenuBar1_Action
Dim Item As MenuItem = Sender
If Item.Text.Contains("About") Then About_action
If Item.Text.Contains("Help") Then Help_action
End Sub
Nope, new year and it still doesn't come together.
I use the following in "Menu Items" in the Visual designer and when I try to compile the Logs tell me I have an "Unterminated array at charactre 53 ...".
Sub FileNew_Action
Log("FileNew clicked.")
End Sub
Sub FileSave_Action
Log("FileSave clicked.")
End Sub
Sub FileExit_Action
Log("FileExit clicked.")
ExitApplication
End Sub
Sub HelpAbout_Action
Log("HelpAbout clicked.")
End Sub
Thanks for the reply. Your example is pretty much the same as I started with originally, however I re-did the exercise with your example and ended with this:
[
{Text: "_Information",
Children:
[
{Text:"_Help", Tag:"FileNew", EventName: "Help"},
{Text: "_About", Tag:"FileSave", EventName: "About"}
]
}
[
It works, I have compared the two and finally spotted my error in the original.