Question

Classic VCL question... but how to do the same within FireMonkey?

I have several standard TControl who can focus...

For instance, in some TEdit, I want to move to the next focusable control if I press the return key

I have try different approach but without success (replacing the key, keychar with 9 when it's 13, ..., forwarding the key events to the form, ...)

Of course, as it is FMX, I'd like a solution which works on all platforms...

If it can avoid to:

  • browse the Children property of the parents,
  • have different pieces of code to address the different platforms
  • hard-code the tab sequence
  • ..., it will be great ;o)
Was it helpful?

Solution

You can place the following code into the OnKeyDown event of the form:

  if Key = vkReturn then begin
    Key := vkTab;
    KeyDown(Key, KeyChar, Shift);   
  end;

If you want that behaviour only for some of the controls, you must call this code in the OnKeyDown events of those controls.

Be aware that the KeyDown must call the TForm.KeyDown to make it work.

(Tested with XE2)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top