websmith wrote:
please help me on this. i would need to use the arrow keys to move
the focus of a button to another. those buttons are arranged in a
matrix. Assuming the current focus is on button at row 5 and column 5
and when the vk_up is pressed, the focus will be changed to the one
in row 4 col 5.

It sounds like you need code that does this:

var
  x, y: Integer;
begin
  for x := 0 to High(ButtonArray[0]) do
    for y := 0 to High(ButtonArray) do
      if ButtonArray[y, x] = Sender then begin
        case Key of
          vk_Down: ButtonArray[y+1, x].SetFocus;
          vk_Up: ButtonArray[y-1, x].SetFocus;
          vk_Right: ButtonArray[y, x+1].SetFocus;
          vk_Left: ButtonArray[y, x-1].SetFocus;
          else exit;
        end;
        Key := 0;
        exit;
      end;
end;

You'll of course need to handle the edge cases, but that should give you the general idea.

If you're displaying the buttons in a matrix, it makes sense to store them in a matrix, too.

i'd tried using the following code :-

procedure TForm1.btn000KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var i : integer;
begin
  if Key = vk_down then
    begin
      for i := 0 to 7 do
      SelectNext(ActiveControl, true, true);
    end;
end;

But somehow the default is in control and move the focus to the next
one to the right only.

The form already handles the navigation keys for you. Try setting the
Key parameter to 0 after you're finished with it so that no later code
will see it.

Besides that, it really seems like it should be the form that controls
the form navigation. Otherwise, each button needs to be aware of all the
other buttons around it.

Also, there seems to be something wrong with your e-mail program. It's
not wrapping long lines. So many people seem to have trouble getting
Outlook Express configured properly.

--
Rob

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to