formsaxaptadynamics-ax-2009

How to stay focused on form field?


I have a form with multiple inputs and buttons for the user. At the start, only the first input is enabled and a few of the buttons.

When the first input is entered, (when the user presses enter), if there is no input or if the input is invalid, then I want the focus to stay on the input field. But when i try using MyControl.setFocus(), the focus is not staying on the field.

How is it possible to keep focus on the same field in this situation?


Solution

  • Using setFocus in the modified method of a form control is a no-go, as it confuses AX tab order.

    You could make the conditional setFocus call from the enter method of the next field control.

    It is not bullet proof, back tab is not handled, but is might do it for you.

    The invalid case should be handled by the validate (or better validateField if a bound field), method of the first field. Also consider setting the Skip property on display only fields.