5

I'm using a simple call to TDialogServiceAsync.InputQuery() with a single input. It just ignores both the Cancel button and the window's X close button.

But the Ok button works fine.

This is my code:

uses
  FMX.DialogService.Async;

procedure TForm1.Button1Click(Sender: TObject);
begin
  TDialogServiceAsync.InputQuery('Title',
   ['Insert value'], ['bla bla'],
  procedure(const AResult: TModalResult; const AValues: array of string)
  begin
    if Aresult = mrOk then
      ShowMessage('Ok!');

    if Aresult = mrCancel then
      ShowMessage('Cancel!'); // this is never called
  end);
end;

If I press Cancel, the InputQuery window doesn't close, and my callback procedure is not called.

How I can make the InputQuery form close when pressing the Cancel button?

I'm using RADStudio 10.1 Berlin.


Edit:

I made a few tests:

  1. On Windows 32 bit cancel button DOES NOT works
  2. On Windows 64 bit cancel button DOES NOT works
  3. On iOS 64 bit cancel button works correctly
  4. On Android 32 bit cancel button works correctly
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
HypeZ
  • 4,017
  • 3
  • 19
  • 34

1 Answers1

6

This is a known bug. There are already bug reports for this issue in Embarcadero's Quality Portal:

RSP-16148 TDialogService.InputQuery() - Cancel button doesn't work

RSP-16670 Problem of TDialogService.InputQuery dialog box.

The latter ticket provides a fix to FMX.DialogHelper.pas:

open

FMX.DialogHelper.pas

find

class function TDialogBuilder.InputQuery(const ACaption: string; const APrompts: array of string;

find

Button := CreateButton(LForm, BorderSize, WorkArea, Layout, SMsgDlgCancel, mrCancel, LForm.ButtonOnClick);

after this line, add

//fix or add by flyign wang.
Button.Cancel := True;
LForm.FCanCancel := True;
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • 1
    With this fix Cancel button works ok, but one cannot close the dialog window by mouse [x], and after pressing ESC button on the keyboard extra pointer error appears. I added: LForm.ModalResult:=mrCancel; below LForm.FCanCancel :=True and commented out Close in TDialogForm.FormKeyDown. Now everything works fine in Windows. I will check mobile platforms later. – zdzichs Apr 07 '17 at 10:49