Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Async InputQuery doesn't handle Cancel button

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
like image 792
HypeZ Avatar asked Mar 21 '17 10:03

HypeZ


People also ask

How do I cancel an async task in Visual Basic?

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.

Why do we need to cancel asynchronous tasks?

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.

How to check if cancel is pressed in InputBox?

Unqualified InputBox is VBA.InputBox. It returns a String, not a date, and you use StrPtr to determine if Cancel was pressed:

How to cancel asynchronous operations in C#?

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


1 Answers

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;
like image 58
Remy Lebeau Avatar answered Oct 17 '22 11:10

Remy Lebeau