FireMonkey in Delphi XE5 introduces a new mechanism for working with modal dialog boxes, due to the fact that the old model is not directly supported on Android. So let's start from this last point, or actually from Windows, where the "modal" form idea originated. The following description is not terribly detailed, but meant to give you an idea of what's at stake.
On Windows, applications have a message processing loop and for each incoming user or application message a user executes some code. VCL and FireMonkey applications have it. The special ShowModal method allows you to stop execution of a message and have a secondary message handling loop. This is how a modal form works, blocking input (like mouse clicks) to the other forms of the same application.
The advantage for a developer is that coding around a ShowModal call is generally much easier than simply showing a secondary form, as the main form can "wait for the modal form to close". While with a modeless approach you need to find a way to communicate back the result of a user operation to the main form, with modal forms this becomes trivial.
As an example, let's consider this classic code, which uses a secondary for with a listbox to let the user select a value:
var dlg: TForm1; begin dlg := TForm1.Create(nil); try // select current value, if avaialble in the list dlg.ListBox1.ItemIndex := dlg.ListBox1.Items.IndexOf(edit1.Text); if dlg.ShowModal = mrOK then // if OK was pressed and an item is selected, pick it if dlg.ListBox1.ItemIndex >= 0 then edit1.Text := dlg.ListBox1.Items [dlg.ListBox1.ItemIndex]; finally dlg.Free; end;
This code works basically unchanged on VCL and FireMonkey.
Apple operating systems (both OS X and iOS) follow the same approach, allowing FireMonkey dialogs to work basically in the same way. So the code above keeps working unchanged on Mac and on the iOS platform, thanks to FireMonkey. Of course, on iOS the situation is not the same, because a secondary form (modal or not) will always cover the entire screen, making it impossible for the user to interact with other forms (again, regardless the secondary form is modal or not).
Android, however, lacks the same concept. Showing a form is not an issue, but if you want to simulate a modal form (blocking the calling code and still receiving events) you need to spawn a separate activity (almost another application). In other words, making modal forms work on Android is quite complex. A non-modal form covers the entire screen, so no big deal, right? This is actually wrong. Although for the user experience, modal or modeless will work the same, for the developer changing the code to account for modeless forms would be a lot of work.
So what happens in Delphi XE5 for Android? The classic ShowModal doesn't work any more (it does raise an exception on Android), but a new overloaded version of the same method is available:
function ShowModal: TModalResult; overload; procedure ShowModal(const ResultProc: TProc<TModalResult>); overload;
The new version, as you can see, is quite special as it uses an anonymous method with the code to be executed when the "supposedly modal" form is closed. The anonymous method received the modal result as parameter. This is basically the code you'd write in the code block within the "if ShowModal" statement.
Here is the same code I had above rewritten using the the new approach (which is compulsory an Android but you can adopt on all platforms):
var dlg: TForm1; begin dlg := TForm1.Create(nil); // select current value, if avaialble in the list dlg.ListBox1.ItemIndex := dlg.ListBox1.Items.IndexOf(Edit1.Text); dlg.ShowModal( procedure(ModalResult: TModalResult) begin if ModalResult = mrOK then // if OK was pressed and an item is selected, pick it if dlg.ListBox1.ItemIndex >= 0 then edit1.Text := dlg.ListBox1.Items [dlg.ListBox1.ItemIndex]; dlg.DisposeOf; end);
Notice that the core code is almost identical, as the anonymous method can refer to controls on the calling form, although it will be executed by the secondary one. There is a difference which is the way the form is freed (forcing destruction on ARC, which should not be required).
So here it is: Anonymous ShowModal, required by Android and available on all FireMonkey platforms in XE5.