FireMonkey: How to focus the next control on vkReturn?

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

I have some standard TControl that can focus ...

For example, in some TEdit , I want to go to the next custom control if I press the return key button

I have a different approach, but without success (replacing a key, keychar with 9, when it is 13, ..., sending key events to the form, ...)

Of course, since this is FMX, I would like the solution to work on all platforms ...

If he can avoid :

  • find the parental property of the parents,
  • have different pieces of code to access different platforms.
  • hard code sequence tabs
  • ..., it will be great; o)
+4
source share
1 answer

You can put the following code in the OnKeyDown event of the form:

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

If you want to use this behavior only for certain controls, you must call this code in the OnKeyDown events for these controls.

Remember that KeyDown must call TForm.KeyDown for it to work.

(Tested with XE2)

+9
source

Source: https://habr.com/ru/post/1440662/


All Articles