I would like to modifiy some of the properties of the popup menu that is created from createPopupMenu. The returned type is of JPopupMenu. I can modify the border color by
menu.background = system.gui.color(255,0,0)
I am looking to modify the following attributes for the popup:
Background color (not just the border)
Fill Area
width
text wrapping
Also, Is there a way to add a separator? I can use the following to add a separator after the menu is created
menu.addSeparator()
But I cannot seem to add anything after the separator that has a function. The following code can adds a separator and another menu item called “XXX”
menu.addSeparator()
menu.add("XXX")
The problem is that there is no function associated with the “XXX” menu item. I have tried the following, but all with errors:
menu.addSeparator()
menu.add("XXX",doMenuItem1)
The code below generates a popup menu on the clicked event of a button.
menu.addSeparator()
menu.add({"XXX":doMenuItem1})
m = []
f = []
def doMenuItem1(event):
import system
system.gui.messageBox("Report 1 selected")
def doMenuItem2(event):
import system
system.gui.messageBox("Report 2 selected")
def doMenuItem3(event):
import system
system.gui.messageBox("Report 3 selected")
import system
m.append("Report 1")
m.append("Report 2")
m.append("Report 3")
f.append(doMenuItem1)
f.append(doMenuItem2)
f.append(doMenuItem3)
menu = system.gui.createPopupMenu(m,f)
menu.background = system.gui.color(255,0,0)
menu.show(event,event.source.parent.x,event.source.parent.y+25)