i am still not sure i understand but i'll improvise - say i am faced with problem of implementing calc keyboard from scratch. Assuming i'll use buttons and then focus would have to move in 4 directions, vertical and horizontal containers may help structurally but not re control. Instead i will task the panel parent with switching focus and buttons will handle only OK press. So each button will have a handler that cares about OK button press and consumes that (returns true for OK and false for all others, so it bubbles up to the panel). Panel then will handle left/right/up/down based on what key it receives and from which button, something like
movement = {left: [-1,0], right: [+1,0], up: [0, -1], down: [0, +1]}
coord_to_id = [
["7", "8", "9"]
["4", "5", "6"],
["1", "2", "3"],
["0", "0", "0"],
]
id_to_coord = {} ' reverse engineer from above table '
for y = 0 to coord_to_id.count() - 1
for x = 0 to coord_to_id[y].count() - 1
id_to_coord[coord_to_id[y][x]] = [x, y]
next
next
coords = id_to_coord[current_button]
change = movement[key_pressed]
new_x = (coords[0] + change[0] + 3) mod 3 ' sorry for the hardcoded brutality normalizing wrap-around '
new_y = (coords[1] + change[1] + 4) mod 4
new_button_id = coord_to_id[new_y][new_x]
this is just typed, not tried (includes a free bug)