Minor requestFocus() bug

The following code is required for requestFocus() to work:

controller.newRecord(false);
entdtl_order = controller.getMaxRecordIndex();

elements.fld_keypunch_code.requestFocus(); <----- WORKAROUND

elements.fld_screen_label.requestFocus(false);

Error Condition:

fld_screen_label has tab sequence = 1
fld_keypunch_code has tab sequence = 2
fld_screen_label is the last named element in the tree (ie - it has the greatest alphanumeric sort in the Editor tree)

If focus is not found elsewhere on the form FIRST (in this case I used the 2nd named element to get form context), requestFocus() will fail.

Manual focus for the named form element will occur if I tab twice after running code that calls element sequence # 1.

Called from the host child form. Contained within a Parent-Child tab form (related). 3.5.1.

Posted to Support as well.

Michael

Hi Michael,

I’ve been playing around with this in 3.1 recently but I believe I have the same behavior in 3.5 (latest versions in both). In other words whenever creating a new record and then requesting focus in a field only ‘momentary’ focus is achieved and ‘true’ focus is lost for the desired field. I don’t know what your support case is or if I can add to it directly but I have found the following also to be true if it helps:

  • if the desired field is the first in the tab order for that form and you first do ‘controller.focusFirstField()’ and then ‘elements.desiredField.requestFocus()’ you will also achieve the desired focus.

  • if after creating the new record you do ‘databaseManager.saveData()’ and then request focus that too will work.

I don’t know if these examples will help the Servoy guys to trouble shoot this issue but perhaps you could add it to your case submission in case it does.

John

I noticed save kind of problem.
I reported a bug with sample solution

I my case it depended also on the AutoSave ON/OFF setting.
When AutoSave is ON, it works like expected, when OFF it doesn’t