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;
end; Check out a Delphi VCL example of creating a custom masked edit for Delphi VCL and then adapt the code to Firemonkey yourself.
FMXExpress.com has over 700 tips and tricks for building cross platform apps on Android, IOS, OSX, Windows, and Linux with a single codebase and single UI using the FireMonkey framework found in Delphi and C++Builder.
FMXExpress covers top cross platform secrets for FireMonkey in C++Builder and Delphi XE5, XE6, XE7, XE8, Seattle, Berlin, Tokyo, Rio, and Sydney.