异步InputQuery无法处理“取消"按钮 [英] Async InputQuery doesn't handle Cancel button
问题描述
我正在通过一个简单的输入对 TDialogServiceAsync.InputQuery()
进行简单的调用.它只是忽略了 Cancel
按钮和窗口的 X
关闭按钮.
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.
但是 Ok
按钮可以正常工作.
But the Ok
button works fine.
这是我的代码:
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;
如果按 Cancel
,则InputQuery窗口不会关闭,并且不会调用我的回调过程.
If I press Cancel
, the InputQuery window doesn't close, and my callback procedure is not called.
当按下 Cancel
按钮时,如何关闭InputQuery窗体?
How I can make the InputQuery form close when pressing the Cancel
button?
我正在使用RADStudio 10.1 Berlin.
I'm using RADStudio 10.1 Berlin.
我做了一些测试:
- 在Windows 32位取消按钮上不有效
- 在Windows 64位取消按钮上不有效
- 在iOS 64位取消按钮上正常工作
- 在Android 32位取消按钮上正常工作
- On Windows 32 bit cancel button DOES NOT works
- On Windows 64 bit cancel button DOES NOT works
- On iOS 64 bit cancel button works correctly
- On Android 32 bit cancel button works correctly
推荐答案
这是一个已知的错误.Embarcadero的质量门户网站中已经存在针对此问题的错误报告:
This is a known bug. There are already bug reports for this issue in Embarcadero's Quality Portal:
RSP-16148 TDialogService.InputQuery()-取消按钮无效
RSP-16670 TDialogService.InputQuery对话框出现问题.
后面的票证提供了对 FMX.DialogHelper.pas
的修复:
The latter ticket provides a fix to FMX.DialogHelper.pas
:
打开
FMX.DialogHelper.pas
找到
class function TDialogBuilder.InputQuery(const ACaption: string; const APrompts: array of string;
找到
Button := CreateButton(LForm, BorderSize, WorkArea, Layout, SMsgDlgCancel, mrCancel, LForm.ButtonOnClick);
在此行之后,添加
//fix or add by flyign wang.
Button.Cancel := True;
LForm.FCanCancel := True;
这篇关于异步InputQuery无法处理“取消"按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!