onFocusGained in a runtime created form

If I dynamically create a form with the solutionModel, I can’t get the onFocusGained and onFocusLost methods work on a field element. The weird thing is that the onAction and onDataChange methods bounded to the same field element instead work correctly. Have anybody faced the same problem? I’m using Servoy 7.4.1 but I’ve also tried in 7.4.2 and in the previous release with the same result.

Here’s a example of my code returning the form created :

	var tForm = solutionModel.newForm(formName, globals.Server.MA_PRESENZE, globals.Table.STORICO, 'leaf_style', false, 360, 150);
		tForm.extendsForm = solutionModel.getForm(forms.svy_nav_base.controller.getName());
		tForm.navigator = SM_DEFAULTS.NONE;
		tForm.view = JSForm.RECORD_VIEW;
		tForm.scrollbars = SM_SCROLLBAR.HORIZONTAL_SCROLLBAR_NEVER | SM_SCROLLBAR.VERTICAL_SCROLLBAR_NEVER;
		tForm.transparent = true;
    
	/** @type JSLabel */
	var tLabel
	/** @type JSField */
	var tField
	/** @type {JSVariable} */
	var tVariable;
	
	var topMargin = 0;
	var sideMargin = 10;
	
	var fldHeight = 20;
	var fldLength = 80;
	var lblHeight = 20;
	var lblLength = 170;
	
	var xLLeft = sideMargin;
	var xLRight = tForm.width - sideMargin - lblLength;//Math.floor(tForm.width / 2) + xLLeft;
	
	var dy = lblHeight + fldHeight;	

	var fieldType;
	var fieldStyle = 'default';
	var fieldFormat = '';
	var fieldAlignment = SM_ALIGNMENT.CENTER;
	var fieldsNo = 10;	
	for (var i = 1; i <= fieldsNo; i++) 
	{
		var dataType = globals.DataType.DATETIME;
		var variableType = = JSVariable.DATETIME;
		tVariable = tForm.newVariable('v' + currField.codice, variableType);
		var row = Math.floor((i - 1) / 2);
		
		tField.name =  currField.codice;
		tField.styleClass = fieldStyle;
		tField.format = fieldFormat;
		tField.horizontalAlignment = fieldAlignment;
		tField.transparent = transparent;
		tField.tabSeq = i;
		
		
		tField.onDataChange = solutionModel.getGlobalMethod('globals','onFocusGainedLost');
		tField.onAction = solutionModel.getGlobalMethod('globals','onActionFocusGainedLost');

                tField.onFocusGained = solutionModel.getGlobalMethod('globals','onFocusGained');
		tField.onFocusLost = solutionModel.getGlobalMethod('globals','onFocusLost');
		
	}
	
	return tForm;
}

Thanks in advance for any help.

that should work fine, are you sure you are attaching a good global method?

There should not be any difference, so you add the same exact method to onaction,ondatachange and the 2 onfocus
then focus is never called?

Sorry, I’ll try to explain with a more understandable code, imagine we have :

      tField.onDataChange = solutionModel.getGlobalMethod('globals','testMethod');
      tField.onAction = solutionModel.getGlobalMethod('globals','testMethod');

      tField.onFocusGained = solutionModel.getGlobalMethod('globals','testMethod');
      tField.onFocusLost = solutionModel.getGlobalMethod('globals','testMethod');

Function testMethod is reached on the onAction and onDataChange but is never reached due to gained or lost focus.

that should just work, make a reproducible example and attach that to a issue in our jira