I am bringing this topic up for two reasons. Firstly, because the Lazarus designer has a rather poor algorithm for finding a new control to focus when an arrow key is pressed. It works, but very often it selects the controls that are not closest to the given direction, and some of them cannot be reached at all, no matter how hard you try. And secondly, because I am looking for the best algorithm that will meet exactly the same assumption as changing the focus in the designer. So you can kill two birds with one stone here.
So, does anyone have a better idea for an algorithm that finds which controls to focus on, based on the position/size of the one currently selected and the four possible search directions (arrow keys)?