FMX MacOS64 button click not firing within printing loop

  

I’m sure this is simple but I’ve spent hours and am missing the solution.

Working in Delphi FMX MacOS64. (This same structure works fine in Delphi VCL).

I have a simple while loop that prints a multi-page report. When the report starts, I show a small “cancel printing” form that shows the page number being printed, and has a Tbutton marked “Cancel”.

I change the page number shown on the form each time through the loop (and that works fine). But the button won’t respond unless I click it multiple times to get focus, and then multiple times again to get an actual click event to occur.

I assume the OS has taken control and is not giving any cycles to check the button. How do I get around it?

I’ve tried setting “repeat click” to true, and that seems to have an effect, but it is set to not repeat the first time until 1/2 second has passed, which is way too long to stop the printing, even if it works on the first repeat.

Here’s the code:

Printer.BeginDoc;
[do some stuff]
iI:=1;
labelcountI:=1;
pageI:=1;
while (iI<readfileSS.count) and (pageI<=ToPageI) do
begin
if readfileSS[iI]<>” then
begin
[do some stuff]
if isZebraB=false then
begin
if (labelcountI = 1) and (iI <> 1) and (pageI >= FromPageI + 1) then
begin
if cancelPrintB=true then endPrintB:=true; //cancelprintB is set to true in the click event
if endprintB=false then
begin
printer.NewPage;
cancelprint.page.text:=IntToStr(pageI); //cancelprint is the form; this line works
if cancelprint.visible then
begin
cancelprint.Invalidate;
cancelprint.CancelBtn.repaint; //have tried with and without this
end
else
begin
cancelprint.show;
end;
application.processmessages;
end
else
begin
cancelprint.close;
end;
if (pageI >= FromPageI) and (endprintB=false) then
begin
[print a lot of stuff]
end;
end;
end;
inc (iI);
end;

Here’s the code for the button. Pretty simple.

procedure TCancelPrint.OKButtonClick(Sender: TObject);
begin
cancelPrintB:=true;
hide;
end;

I have put a message in the OnClick code, and confirmed that it is not firing.

As I said, this must be easy, but apparently not for me. Appreciate any help.

Thanks.

Scott

Comments are closed.