Servoy 6 windows plugin...

I’m trying to use the new windows plugin for a pop up menu. I’m following the example code pretty much exactly and the popup works fine but there is this annoying warning that I don’t understand. My code is this:

function onActionShowChoices(event) {
	var popupmenu = plugins.window.createPopupMenu()
	
	var menuitem0 = popupmenu.addMenuItem('View By Sample Names',RunFunctionToView)
	var menuitem1 = popupmenu.addMenuItem('View By Human Names',RunFunctionToView)
	var menuitem2 = popupmenu.addMenuItem('View By Medrec',RunFunctionToView)
	var menuitem3 = popupmenu.addMenuItem('View By Sampleid',RunFunctionToView)
		
	var source = event.getSource()
	if (source != null)
	{
		popupmenu.show(source);
	}		
}

Runs fine but for the line ‘var source = event.getSource()’ I get this warning:

Variable source hides a property

And for the line ‘popupmenu.show(source);’ I get this:

The method show(RuntimeComponent,Number,Number) in the type Popup is not applicable for the arguments (Object)

If I change the variable name from ‘source’ to something else then the first warning goes away but not the second. I don’t understand what those warnings mean. And even though the function works perfectly, it offends my sense of symmetry to have those warnings come up! Can anyone enlighten me as to what they mean and how to fix them? I think I followed the example code exactly.

I got this a lot as well and had to change the name of the var so it does not clash.
After you make the change try Project clean to see if it goes away.

Changing the name from source fixed the one and getting the x/y coordinates with ‘event.getX()’ and ‘event.getY()’ and putting those instead as ‘popmenu.show(x,y)’ got rid of the other. But I don’t understand why the other doesn’t work since that is directly what is given in the example code…

Hi John,

See this thread for why you get a warning on .show(source): http://www.servoy.com/forum/viewtopic.php?f=22&t=16728.

As for the warning “Variable source hides a property”: it means that higher up in the hierarchy of code there is already a variable declared with the name “source”. Higher in the hierarchy means either a form variable if the method you pasted is a form method, or a global variable if the method you pasted is a global method.

Paul