I'm building a long menu using MenuBar in B4J, and in the MenuBar1_Action event, I want to avoid writing a long If...Then or Select Case block for each menu item.
All my menu items will eventually call the same method like this:
Each MenuItem has a Tag, for example:
In the event:
Is it possible (and safe) to use the Tag property to automate these calls, maybe splitting the tag and calling the corresponding module dynamically?
Any suggestions or best practices?
All my menu items will eventually call the same method like this:
B4X:
x.Show("Module", m.Text)
Each MenuItem has a Tag, for example:
JSON:
{
Text: "Consulta com IA",
Tag: "consultaIA, Consulta com IA"
}
In the event:
B4X:
Private Sub MenuBar1_Action
Dim m As MenuItem = Sender
If m.Text = "Consulta com IA" Then ConsultaIA.Show("ConsultaIA", m.Text)
End Sub
Is it possible (and safe) to use the Tag property to automate these calls, maybe splitting the tag and calling the corresponding module dynamically?
Any suggestions or best practices?