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:
Cancel an Async Task or a List of Tasks (Visual Basic) You can set up a button that you can use to cancel an async application if you don't want to wait for it to finish. By following the examples in this topic, you can add a cancellation button to an application that downloads the contents of one website or a list of websites.
The need to cancel asynchronous tasks emerged shortly after introducing Promise into ES2015 and the appearance of several Web APIs supporting the new asynchronous solution. The first attempt focused on creating a universal solution that could later become a part of the ECMAScript standard.
Unqualified InputBox is VBA.InputBox. It returns a String, not a date, and you use StrPtr to determine if Cancel was pressed:
Presentations Toggle searchToggle menu Cancel asynchronous operations in C# Running asynchronous code is pretty easy with .NET and C#. As we sometimes need to cancel an ongoing asynchronous operation we will see, throughout this post, how to cancel tasks using CancellationToken, even for non-cancellable tasks. 6 minute read John Thiriet
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With