Difference between revisions of "Mac Buttons"

From Free Pascal wiki
Jump to navigationJump to search
(Deleted categories because they are placed in template)
m (Fixed page link)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{Platform only|macOS}}
 
{{Mac Buttons}}
 
{{Mac Buttons}}
  
{{Platform only|Mac OS X}}
 
 
By default, the button placed onto a form by Lazarus is 75 width by 25 height, which is not the standard for Mac Applications.
 
By default, the button placed onto a form by Lazarus is 75 width by 25 height, which is not the standard for Mac Applications.
  
Line 10: Line 10:
  
 
==CODE FOR A SINGLE BUTTON:==
 
==CODE FOR A SINGLE BUTTON:==
<syntaxhighlight>
+
 
 +
<syntaxhighlight lang="pascal">
 
procedure TForm1.FormCreate(Sender: TObject);
 
procedure TForm1.FormCreate(Sender: TObject);
 
begin
 
begin
Line 19: Line 20:
 
==CODE FOR ALL BUTTONS:==
 
==CODE FOR ALL BUTTONS:==
  
<syntaxhighlight>
+
<syntaxhighlight lang="pascal">
 
procedure TForm1.FormCreate(Sender: TObject);
 
procedure TForm1.FormCreate(Sender: TObject);
 
var
 
var
Line 29: Line 30:
 
end;
 
end;
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
== See also ==
 +
 +
*[[Introduction to platform-sensitive development]]
 +
*[[Mac Show Application Title, Version, and Company]]
 +
*[[Add an Apple Help Book to your macOS app]]
 +
*[[macOS Programming Tips]]

Latest revision as of 07:34, 18 December 2019

macOSlogo.png

This article applies to macOS only.

See also: Multiplatform Programming Guide

English (en) русский (ru)

By default, the button placed onto a form by Lazarus is 75 width by 25 height, which is not the standard for Mac Applications.

In order for buttons to appear oval, make the button height 22 maximum.

This can be done by setting the button height directly or through code.


CODE FOR A SINGLE BUTTON:

procedure TForm1.FormCreate(Sender: TObject);
begin
  Button1.Height := 22;
end;

CODE FOR ALL BUTTONS:

procedure TForm1.FormCreate(Sender: TObject);
var
  I: Integer;
begin
  for I := 0 to Form1.ControlCount - 1 do begin
    if (Form1.Controls[I].ClassType = TButton) then Form1.Controls[I].Height := 22;
  end;
end;

See also