Hello,
Im new to B4J. In the Designer I add a context menu with 3 items to a button.
Can anyone help me with a B4J snipped how to get the click event if a menu item is selected? Button_click will not work on right mouse click.
I think a way is to use Mouse_Click Event and to look if the right mouse button was clicked but how?
Next if that is solved is how to intercept the selecteditem click?
Menus in the internal designer are declared as JSON strings. If you have never worked with the JSON format then it is a good time to learn this format. It is simple and very popular. Short tutorial: http://www.vogella.com/tutorials/JSON/article.html In our case the JSON string describes a list...
I am not sure I do this correctly but it works for me.
B4X:
Dim ctx As ContextMenu
ctx.Initialize("ctx")
Dim m1 As MenuItem
m1.Initialize("Item 1", "ctx")
Dim m2 As MenuItem
m2.Initialize("Item 2", "ctx")
Dim m3 As MenuItem
m3.Initialize("Item 3", "ctx")
ctx.MenuItems.AddAll(Array(m1, m2, m3))
Button1.ContextMenu = ctx