I have what seems to be a simple error trying to create a popup menu. I can get the menu to be created and shown if I use the code shown below when showing it using the hard coded coordinates (10,10) for instance.
But when I copy code from the Wiki to display the menu just below the object to which the method is attached, I get the following error:
ReferenceError: “event” is not defined.
This error occurs on the line: var source = event.getSource()
Maybe there is something simple I am overlooking, but I was hoping to just copy this little bit of code from the Wiki and have it working.
Another interesting issue is that I don’t see the mnemonic key getting displayed in an underlined manner. I have set this as parameter #4 of the addMenuItem function for a few of these menu items.
My configuration:
MacOSX 10.6.4
Servoy 5.2.2 SmartClient
function toolmenu_mpr_ppm() {
var ppMenu = plugins.window.createPopupMenu();
var menuitem0 = ppMenu.addMenuItem('BackColor', null, null, 'b');
var menuitem1 = ppMenu.addMenuItem('Red', null, null, 'r');
var menuitem2 = ppMenu.addMenuItem('Green', null, null, 'g');
var menuitem3 = ppMenu.addMenuItem('Blue', null, null, 'b');
var menuitem4 = ppMenu.addMenuItem('White', null, null, 'w');
//show popup menu
var source = event.getSource()
if (source != null) {
ppMenu.show(source);
}
// ppMenu.show(10,10);
}