Hi,
Android FMX Delphi Rio
In some examples the TMSFMXTaskDialog starts with "execute".
The actual component has only "show".
Is there an example how to use TMSFMXTaskDialog ?
Especially thomething like:
TMSFMXTaskDialog.title := 'Do you want to delete this?';
if TMSFMXTaskDialog1.result = mrOk then
begin
TMSFMXTaskDialog.title := 'Shure?';
if TMSFMXTaskDialog1.result = mrOk then
begin
deleteAll;
end;
end;
ok, it works for me with windows and android.
if someone is interested how, this is how I did it:
I defined 3 actions:
acDoOk: TAction;
acDoCancel: TAction;
acDoOkReally: TAction;
then I called a selfdefined object this way:
SC_GlobalDialog.DialogExecute( FHaupt_frm,
'Title',
'Instruction',
'Content',
acDoOk, acDoCancel );
and in the action "acDoOk" I call the confimation dialog:
SC_GlobalDialog.DialogExecute( FHaupt_frm,
'Test 2',
'Read carefully',
'and press Ok',
acDoOkReally, acDoCancel );
finally in the action "acDoOkReally" there is the final function.
Here comes the unit with the object containing the dialog.
It is for just two Buttons.
you know a better solution, I would like to know, if it works on all platforms.
quick, dirty and works for me:
unit SC_GlobalDialog;
interface
uses System.Classes, System.SysUtils, System.UITypes,
FMX.ActnList, FMX.Forms,
FMX.TMSTaskDialog;
Type
TGlobalDialog = class
private
Fac1,
Fac2: TAction;
public
TMSFMXTaskDialog1: TTMSFMXTaskDialog;
constructor Create(owner: TComponent;
cTitle, cInstruction, cContent: string);
destructor Destroy; override;
protected
procedure TMSFMXTaskDialog1DialogButtonClick(Sender: TObject;
ButtonID: Integer);
procedure TMSFMXTaskDialog1DialogClose(Sender: TObject;
var CanClose: Boolean);
published
end;
function DialogExecute( Sender: TObject;
cTitle, cInstruction, cContext: string;
ac1, ac2: TAction): boolean;
var
myDialog: TGlobalDialog;
const
unit_name = 'SC_GlobalDialog.';
implementation
constructor TGlobalDialog.Create( owner: TComponent;
cTitle, cInstruction, cContent: string );
var
cFunctionname: string;
begin
inherited create;
try
try
cFunctionname:= unit_name + 'Create';
TMSFMXTaskDialog1 := TTMSFMXTaskDialog.Create(owner);
TMSFMXTaskDialog1.OnDialogClose := TMSFMXTaskDialog1DialogClose;
TMSFMXTaskDialog1.OnDialogButtonClick := TMSFMXTaskDialog1DialogButtonClick;
TMSFMXTaskDialog1.Title := cTitle;
TMSFMXTaskDialog1.InstructionText := cInstruction;
TMSFMXTaskDialog1.Content := cContent;
// TMSFMXTaskDialog1.CommonButtons := [OK, Yes, No, Cancel, Retry, Close];
TMSFMXTaskDialog1.CommonButtons := [Yes, No]; // (System.UITypes.mrYes) if different correct DialogbuttonClick
TMSFMXTaskDialog1.show( );
except
on E:Exception do begin
end;
end;
finally
end;
end;
destructor TGlobalDialog.Destroy;
var
cFunctionname: string;
begin
inherited;
try
try
cFunctionname:= unit_name + 'Destroy';
TMSFMXTaskDialog1.free;
TMSFMXTaskDialog1 := nil;
except
on E:Exception do begin
end;
end;
finally
end;
end;
procedure TGlobalDialog.TMSFMXTaskDialog1DialogButtonClick(Sender: TObject;
ButtonID: Integer);
var
cFunctionname: string;
begin
try
try
cFunctionname:= unit_name + 'TMSFMXTaskDialog1DialogButtonClick';
if ButtonID = System.UITypes.mrYes then begin
Fac1.execute;
end else begin
Fac2.execute;
end;
except
on E:Exception do begin
// ExceptionLog( cFunctionname, e.Message);
end;
end;
finally
end;
end;
procedure TGlobalDialog.TMSFMXTaskDialog1DialogClose(Sender: TObject;
var CanClose: Boolean);
var
cFunctionname: string;
begin
try
try
cFunctionname:= unit_name + 'TMSFMXTaskDialog1DialogClose';
CanClose := TRUE;
self.Free;
except
on E:Exception do begin
end;
end;
finally
end;
end;
function DialogExecute( Sender: TObject;
cTitle, cInstruction, cContext: string;
ac1, ac2: TAction): boolean;
var
cFunctionname: string;
begin
try
try
cFunctionname:= unit_name + 'DialogExecute';
myDialog := TGlobalDialog.Create ( Sender as TForm,
cTitle, cInstruction, cContext );
myDialog.TMSFMXTaskDialog1 := TTMSFMXTaskDialog.Create(Sender as TForm);
myDialog.Fac1 := ac1;
myDialog.Fac2 := ac2;
except
on E:Exception do begin
result := FALSE;
end;
end;
finally
end;
end;
end.
Thank you for your feedback!