B4J Question How to get EventName of a MenuItem via code?

Mashiane

Expert
Licensed User
Longtime User
Ok, perhaps this is impossible. The main menu designer will be called MenuBar1 for example, you trap the sender events there and detect the tag/text property.

if each other menu item has an event, in your code there should be Sub menu123_Action for example, I had thought that perhaps just like .Enabled / .Visible when investigating menu items, one could get that property.

Example, the code below detects the menu and menuitem and uses the text property to make a menu visible/not. I assumed that perhaps one could get the .EventName property of the MenuItem - if possible.

B4X:
Sub MenuItemVisible(MBar As MenuBar, MainMenu As String, MenuItem As String, bVisible As Boolean)
    Dim lMenus As List = MBar.menus
    For Each strMenu As Menu In lMenus
        Dim mText As String = strMenu.text
        If mText.EqualsIgnoreCase(MainMenu) Then
            For Each mi As MenuItem In strMenu.MenuItems
                Dim miText As String = mi.Text
                If miText.EqualsIgnoreCase(MenuItem) Then
                    mi.Visible = bVisible
                    Return
                End If
            Next
        End If
    Next
End Sub
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I don't think the event name is stored for any view, so probably not.
 
Upvote 0
Top