OnFocusLost...

I have a method that is triggered by a field through OnFocusLost. In this global method I use the application.getMethodTriggerElementName() to get the name of the field that has lost focus. However the element name that I get is not the name of the field that has LOST focus but rather the field that GAINS focus after losing focus in the other field for some reason. (There is no method on that 2nd field for OnFocusGained). This seems bizarre to me.

Does anyone else have this problem? (Basically what I am doing is setting a global method and attaching it to various fields that I want to have entered in all caps. Seemed to me best to trigger it with OnFocusLost…)

john.allen:
However the element name that I get is not the name of the field that has LOST focus but rather the field that GAINS focus after losing focus in the other field for some reason.

Hi John,

In my end it is working Perfectly.
It is returning the name of the field which has triggred the onfocusLost event not the one who is getting the focus after that.

So, please check the names of the fields and the method.

Hope it will help.

Hi Ars,

Interesting. I’ve been running this in ‘debug’ mode and it works as I said above. However when I run it ‘normally’ then the method does work as designed and as you suggest:

var elementName = application.getMethodTriggerElementName();
var val = currentcontroller.getDataProviderValue(elementName);
if (!val)
{
	return;
}
currentcontroller.setDataProviderValue(elementName, val.toUpperCase())

I think the ‘debug’ throws it off in some way. What occurs to me is that as soon as the focus is lost the cursor has moved to the next field and the focus is there. At that point the debugger kicks in and the focus is again ‘lost’ as the UI switches to the debugger. Thus the method/debugger returns the ‘focus lost’ as being the second field (which also has that same method attached to it).

Great :wink: