B4J Question [SOLVED] How to add event to runtime created CheckedMenuItem?

rosippc64a

Active Member
Licensed User
Longtime User
Hello everyone!
I use Menubar in one of my B4J applications. Since the app works for several companies, the menu structure, language, etc. may vary. Therefore I load the menu items from a json file (thanks @Erel ). The only thing missing is the event of CheckedMenuItem to detect when they are clicked. With my code I create the menu item nicely, the checkbox works, but I don't know how to assign a click event to it.
Does anyone know the solution?

CheckedMenu:
private Sub CheckedMenu(EventName As String,Text As String, pTag As String, value As Boolean) As MenuItem 
    Dim TJO As JavaObject
    TJO.InitializeNewInstance("javafx.scene.control.CheckMenuItem",Array(Text))
    TJO.RunMethod("setSelected",Array(value))
    TJO.RunMethod("setUserData",Array(pTag)) 'Is it menuitem.tag?
    Return TJO
End Sub

I can see where I should search, but it is complicated for me:
B4X:
    Action menuAction = new MenuAction(xxxx, yyyy);
    item.setOnAction(menuAction);

thanks
Steven
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…