Forum > macOS / Mac OS X

PaintBox not working under macOS trunk (M1)?


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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    Label1: TLabel;    PaintBox1: TPaintBox;    Panel1: TPanel;    procedure Button1Click(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);begin  with PaintBox1 do  begin    with canvas do    begin       moveto(150,150); //ClientCenter       lineto(250,250);    end;  end;  Label1.Caption:='Line drawn';end; end.  

Put the drawing code in the PaintBox OnPaint event handler so it can redraw itself on refresh. It is not a MacOS bug.


[0] Message Index

Go to full version