Programming => Operating Systems => macOS / Mac OS X => Topic started by: mrmaxmusterman on July 10, 2021, 02:15:37 am

Title: PaintBox not working under macOS trunk (M1)?
Post by: mrmaxmusterman on July 10, 2021, 02:15:37 am
So im currently working on a project that involves the use of a paintbox and a panel in combination with a canvas to draw.
Just before starting on the main project, I wanted to check whether or not lazarus (v.2.3.0 r65372 trunk through Fpcupdeluxe) is capable of displaying such drawings. Sadly, this is just not the case (at least with my current project).
Instead of drawing a line, the whole paintbox stays empty while lazarus moves forward in the procedure (label). In the attached screenshot, you can see the result of the form after clicking on "draw". Down below you can also find the current code of my project. Idk if I left anything unconfigured in lazarus itself or my project but following the same steps (designing the form, inserting buttons, labels etc., writing code under linux (Debian 10 ARM64) and Windows 10 (ARM64) results in the program working perfectly fine. Is it maybe a known problem in the trunk MacOS build? Feel free to leave a comment if you have any clue whatsoever as to why this is happening.

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  3. {$mode objfpc}{$H+}
  5. interface
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls;
  10. type
  12.   { TForm1 }
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     Label1: TLabel;
  17.     PaintBox1: TPaintBox;
  18.     Panel1: TPanel;
  19.     procedure Button1Click(Sender: TObject);
  20.   private
  22.   public
  24.   end;
  26. var
  27.   Form1: TForm1;
  29. implementation
  31. {$R *.lfm}
  33. { TForm1 }
  35. procedure TForm1.Button1Click(Sender: TObject);
  36. begin
  37.   with PaintBox1 do
  38.   begin
  39.     with canvas do
  40.     begin
  41.        moveto(150,150); //ClientCenter
  42.        lineto(250,250);
  43.     end;
  44.   end;
  45.   Label1.Caption:='Line drawn';
  46. end;
  48. end.
Title: Re: PaintBox not working under macOS trunk (M1)?
Post by: VTwin on July 10, 2021, 06:38:05 am
Put the drawing code in the PaintBox OnPaint event handler so it can redraw itself on refresh. It is not a MacOS bug.
TinyPortal © 2005-2018