Async InputQuery doesn't handle Cancel button

我们两清 提交于 2021-02-07 14:29:19

问题


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

回答1:


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;


来源:https://stackoverflow.com/questions/42924482/async-inputquery-doesnt-handle-cancel-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!