If you are doing any kind of validation of fields with a TEdit component in Delphi XE7 Firemonkey you may be looking for a TMaskEdit control. Delphi VCL has a TMaskEdit but Firemonkey on Android, IOS, Windows, and Mac does not ship with one. This is easily solved however with some custom code in the OnKeyDown event. Basically the general idea is that when the user presses a key you check the key being pressed and the contents of the edit to see if it matches what you want it to accept. If the key should not be allowed you set it’s value to #0. I adapted my code snippet from a Delphi VCL example. One item of note is that I use String.IndexOf() in the code snippet which has cross platform support verses the Pos() function which gives you different values depending on if it is a mobile platform (0 based) or a desktop platform (1 based). This code snippet is really just to get you started with a mask edit solution. There are other things you will need to take into account as well like for example on Android the user can select entire auto complete words from the keyboard. You’ll have to come up with your own code for the OnChange event to handle those. TMS Pack for Firemonkey also has some edit components that support masking. The code snippet sample below shows how to filter for a decimal. It should also work in Appmethod.
procedure TForm1.MyEditKeyDown(Sender: TObject; var Key: Word;
var KeyChar: Char; Shift: TShiftState);
if not CharInSet(KeyChar,['.', '0'..'9']) then
KeyChar := #0;
if (KeyChar='.') AND (MyEdit.Text.IndexOf('.')>-1) then
KeyChar := #0;
Create A Custom Mask Edit Validation Event In Delphi XE7 Firemonkey On Android And IOS by Delphi XE5 XE6 XE7 XE8 10 Seattle Berlin Firemonkey, Delphi Android, Delphi IOS is licensed under a Creative Commons Attribution 4.0 International License.