### MenuBar EventName not set

MenuBar EventName not set: If the EventName for a Menuitem is not set, the MenuBar event name will be used.
If the Menubar is defined as
Private MenuBar1 As MenuBar
Then the MenuBar1 Action is defined as
`Sub MenuBar1_Action
End Sub`
This will handle the events of all the menu items except the ones that explicitly set the event name.
To capture the MenuItem selected, use
`Sub MenuBar1_Action
Dim mi As MenuItem = Sender
Log(mi.Text)
End Sub`
Output Example:
_New
_Save
for a menu defined as
[{Text: "_File",
Children: ["_New", "_Save", ...
To better handle Menuitems selected, define a Tag for a Menuitem:
[{Text: "_File",
Children:
[
{Text:"_New", Tag:"FileNew"},
{Text: "_Save", Tag:"FileSave"},
{Text: "_Exit", Tag:"FileExit"}
]},
Output Example:
Text: _New, Tag:FileNew
Text: _Save, Tag:FileSave
In the MenuBar1_Action the Tag can be checked:
`Sub MenuBar1_Action
Dim mi As MenuItem = Sender
Log("Text: " & mi.Text & ", Tag:" & mi.Tag)
Dim menutag As String = mi.Tag
If menutag.EqualsIgnoreCase("filenew") Then Log("MenuItem FileNew clicked.")
End Sub`
One step further is to define the EventName. See B4J HowTo MenuBar EventName.

Changed: , Category: Visual Designer, File: T6C276M2050.htm, ID: 2050