In the multiform demo, the modal form of type TForm2 is called using
TAwait.ExecP<TModalResult>(newform.Execute);
If I set TForm2 button's ModalResult to mrOk, I would expect that I can check the ModalResult this way:
if TAwait.ExecP<TModalResult>(newform.Execute) = mrOk then
But this doesn't work. I have to do
TAwait.ExecP<TModalResult>(newform.Execute);
if newform.ModalResult = mrOk then
I cannot reproduce this.
Test:
// excute form and wait for close
if TAwait.ExecP<TModalResult>(newform.Execute) = mrOK then
console.log('ok')
else
console.log('cancel');
with in the launched form:
procedure TForm2.WebButton1Click(Sender: TObject);
begin
ModalResult := mrCancel;
end;
procedure TForm2.WebButton2Click(Sender: TObject);
begin
ModalResult := mrOK;
end;
it returns the proper modal result value depending on the button clicked.
I set TForm2.WebButton2's ModalResult property in Object Inspector to mrOk
and left TForm2.WebButton2Click as it was
procedure TForm2.WebButton2Click(Sender: TObject);
begin
Close;
end;
Remove the Close call in that case as setting ModalResult for the button already causes the form to close