B4J Question B4J Designer: Code for Context Menus?

ShaneG30

Well-Known Member
Licensed User
Longtime User
With the B4J Designer, you can add ContextMenus like the below to any control.

Example ContextMenu: ["Item 1", "Item 2"]

However, what is the code for actually using them? I've tried the below code and it doesn't work.

B4X:
Public Sub MenuItem_Action
    Dim Mi As MenuItem = Sender
    Log (Mi.Text)
End Sub

Any help would be appreciated!
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

ShaneG30

Well-Known Member
Licensed User
Longtime User
Upvote 0

Daestrum

Well-Known Member
Licensed User
Longtime User
When you add the code for the context menu in the designer, add the EventName you want for the item too.
At its simplest use
B4X:
[{Text: "item1",EventName: "one"},{Text: "item2",EventName: "two"}]
Now when item1 is clicked it will trigger
B4X:
Sub one_Action
...
End Sub
 
Upvote 0
Top