Recent

Author Topic: Changing focus with the arrow keys – a better algorithm is needed  (Read 2547 times)

flowCRANE

  • Hero Member
  • *****
  • Posts: 883
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)?
Lazarus 3.4 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on a retro-style action/adventure game (pixel art), programming the engine from scratch, using Free Pascal and SDL.

 

TinyPortal © 2005-2018