Request focus help

I have a method that executes when the company_text field is changed. I need to confirm that company name has been entered before company_text (a checkbox) is changed from empty to filled. All of the method works as expected except that the requestFocus just doesn’t happen!

If I run the requestFocus on its own it works fine, but at the the end of this method - nothing!

controller.saveData();
if ( company_text == ‘company’ && company_name ==‘’||company_text == ‘company’ && company_name == null)
{
plugins.dialogs.showErrorDialog( “Missing data”, “Please enter company name first!”, ‘OK’);
company_text = null;
forms.contacts_card.elements.company_name.requestFocus();
}

does anyone know why the requestFocus is not working?

to test: if you remove the controller.saveData call does it work then?

If still not, then can you give me a small example?

Hai Drookwood, I noticed that you do the requestfocus with a form name attached. Does that mean this method is outside this form (on another form)?

BTW why don’t you do:

if (company_text == 'company' && !company_name) 

Ciao

jcompagner:
to test: if you remove the controller.saveData call does it work then?

I have tried this now:

if(company_text == ‘company’ && !company_name)
{
plugins.dialogs.showErrorDialog(“Missing data”", “Please enter company name first!”, “OK”);
company_text = ‘’;
elements.company_name.requestFocus();

Result is the same as before: everything else works but focus is not gained on the company_name field

If still not, then can you give me a small example?

I’ll see if can set up a small test file and send it!

IT2BE:
Hai Drookwood, I noticed that you do the requestfocus with a form name attached. Does that mean this method is outside this form (on another form)?

No, the method is on the form, but removing the formname also makes no difference!

BTW why don’t you do:

if (company_text == 'company' && !company_name) 

Thanks - much more elegant!

Thanks for the compliment but it doesn’t help solving the thing unfortunately :?

I don’t have any answers/questions anymore… A bug?

I’m having a similar situation. All I want to do is create a new record and have a field get the focus.

controller.newRecord();
elements.field.requestFocus();

If I only use the requestFocus it works fine. I’m running RC9 under MacOS 10.3.3.

Am I doing something wrong?

Ronnie

what view are you in?
List/Table or record?

for list/table you have to have RC10..

There you have it, it’s a list view. Is RC10 available? because Servoy can’t find any updates.

Thanks,

Ronnie

not yet.. will be there very soon