jsMethod not fired in find mode

Hello,

My onFind method creates a button with a method, but it doesn’t work in find mode.

	var form = controller.getName()
	var frm = solutionModel.getForm(form)
	var ofgMeth = solutionModel.newGlobalMethod('function totRec(event){var source = event.getElementName();globals.g_search = source}')
        var x = frm.newButton('button',0,0,20,20,ofgMeth)
        x.name = 'button'
	forms[form].controller.recreateUI()
        controller.find()

If I remove controller.find() it works.

did you include something like:

if(false) controller.search()

in your search method?
Otherwise a method won’t be triggered in find mode.

In Servoy 6 you don’t need that anymore, there is a JSDoc property to allow method execution in Find mode, it’s called @AllowToRunInFind, check the docs to know more about it.

thnkx Nicola!

with all the nice new features in 6, it’s easy to forget some. :-)

Thank you Nicola,

I will try to find out how it works. I just read the wiki, it’s a bit of a jungle. :shock:

Ok, @AllowToRunInFind is added, but it still doesn’t work. Could it that it doesn’t apply for the solutionModel?

/**
 * @AllowToRunInFind
 * 
 * @properties={typeid:24,uuid:"D4C3C1A6-4266-480F-969A-16B7FDCA3E39"}
 * 
 */
function onFind()
{
	controller.find()
	var form = controller.getName()
	var frm = solutionModel.getForm(form)
	var ofgMeth = solutionModel.newGlobalMethod('function totRec(event){var source = event.getElementName();globals.g_search = source}')
        var x = frm.newButton('button',0,0,20,20,ofgMeth)
        x.name = 'button'
	forms[form].controller.recreateUI()

}

Irene, it’s the ‘ofgMeth’ function that should be allowed to run in find mode.

The ‘onFind’ function will run whenever your solution is still in browse mode.