onFocusLost runs unexpectedly

Hi!
I have set onFocusGained and onFocusLost events on a field in a form where a record is created onFocusGained and deleted if empty onFocusLost.
However, after clicking in the field and the record has been created AND saved, onFocusLost runs immediately and removes the new record before I can type anything in the field. This does not happen if the record is not saved. Why does it happen and is it the expected Servoy behavior?

Thanks,
Maria

databaseManager.saveData() will remove focus from fields. This is expected behavior.

Saving data would normally result in no records being in edit state any more (if there are no validation problem or other errors when saving).
When you have focus on a field that record is considered “edited” - that is why saveData() will make fields loose focus.

Andrei Costescu:
databaseManager.saveData() will remove focus from fields. This is expected behavior.

Saving data would normally result in no records being in edit state any more (if there are no validation problem or other errors when saving).
When you have focus on a field that record is considered “edited” - that is why saveData() will make fields loose focus.

This is the problem, Andrei: I have to save data at that point to refresh the relation between related foundsets for Servoy to recognize a new record created without using the relation. The scenario is: click in the field, created record (as the form might have no record underneath), save record, enter data in the field, click on another tab with a related form, click back and be able to see the field data. If I don’t save, then go to another tab and go back I won’t see the field data because the field is on a related tab and the relation is not refreshed until the data is saved…

I’ll try putting the record creation on some other event of the form but being able to refresh the related foundset without saving would be a good idea. I already posted a topic with that question, if you could add some input, please, do. viewtopic.php?f=22&t=12905

Cheers,
Maria

You could also request focus back into the field you want it after saveData().

Andrei Costescu:
You could also request focus back into the field you want it after saveData().

Thanks Andrei.
I changed the strategy for creating new records and do it using a relation now, so it does not require saving straight away but thanks for the tip :D

Cheers,
Maria

We migrated to Version 5 and are having a similar problem again.
When the user clicks in the field the onFocusGained runs and then immediately onFocusLost does.
I’m not saving data or doing anything else in onFocusGained method.
This used to work fine in Version 4.
How come it loses focus?

Cheers,
Maria

Maria,

In a simple set-up this does not happen, can you show this in a small sample?

Rob

rgansevles:
Maria,

In a simple set-up this does not happen, can you show this in a small sample?

Rob

I’m afraid it’s a part of a large solution and we can’t reproduce it in a sample :(