Search code examples
formsaxaptadynamics-ax-2012-r2

AX 2012 FormGridControl.gotFocus not working


I have a problem with the FormGridControl.gotFocus method. The method works if the grid is empty. If the grid contains data it does'nt work...

I this a bug or can i do something else?


Solution

  • The gotFocus on container controls may not be activated because a contained control got focus instead. Put another way: setting focus on a control does not activate the gotFocus methods of the containing container controls.

    Thus it may be useless as tool for determining, what has focus.

    Often a better way is to check the selectedControl of the FormRun class using the contains method:

    boolean inGr = element.selectedControl() && group.contains(element.selectedControl());
    

    This cannot be used in buttons of cause because the button gets focus when clicked!
    It may be of use in the task method and other control methods.