onFocusGained with showFormInDialog

I use the following method in form "smurg1"to call another form in a dialog, to select a value:
“application.showFormInDialog(forms.Transport,-1,-1,-1,-1);”
“Transport” is table-view, to select a value, and this method is triggered by “onFocusGain”.
A button selects the value and closes the dialog with following code:
“forms.smurg1.nagr = nrvetsiging;
application.closeFormDialog();”
with nrvestiging and nagr is a dataprovider.

Every time the the second method, to select the value, is run, the first method runs (this happens only ones) again.

What do I do wrong? Sorry, still beginner with servoy.

please send a small example demonstrating this

I’m not able to upload an example from here. I’l try again tonight.

Gert

the problem is that when you are closing the formDialog, the textfield get’s the focus again and it fires openDialog again. The strange thing is why it doesn’t do that a third time!

To fix this you have to transfer the focus first to another element before calling show form in dialog

i placed a extra button on the form and do now something like this:

elements.bt.requestFocus()
application.showFormInDialog( forms.test2, -1,  -1,  -1,  -1,"Choose your preference")

Thanks for your help Johan!

Gert