Recent

Author Topic: PaintBox not working under macOS trunk (M1)?  (Read 2452 times)

mrmaxmusterman

  • New Member
  • *
  • Posts: 18
PaintBox not working under macOS trunk (M1)?
« 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;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     Label1: TLabel;
  17.     PaintBox1: TPaintBox;
  18.     Panel1: TPanel;
  19.     procedure Button1Click(Sender: TObject);
  20.   private
  21.  
  22.   public
  23.  
  24.   end;
  25.  
  26. var
  27.   Form1: TForm1;
  28.  
  29. implementation
  30.  
  31. {$R *.lfm}
  32.  
  33. { TForm1 }
  34.  
  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;
  47.  
  48. end.
  49.  
  50.  

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: PaintBox not working under macOS trunk (M1)?
« Reply #1 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.
« Last Edit: July 10, 2021, 06:46:14 am by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

 

TinyPortal © 2005-2018