Difference between revisions of "Mac Buttons"

From Free Pascal wiki
Jump to navigationJump to search
(Platform template added.)
m
Line 7: Line 7:
  
  
'''CODE FOR A SINGLE BUTTON:'''
+
==CODE FOR A SINGLE BUTTON:==
 +
<syntaxhighlight>
 +
procedure TForm1.FormCreate(Sender: TObject);
 +
begin
 +
  Button1.Height := 22;
 +
end;
 +
</syntaxhighlight>
  
    procedure TForm1.FormCreate(Sender: TObject);
+
==CODE FOR ALL BUTTONS:==
    begin
 
        Button1.Height := 22;
 
    end;
 
  
'''CODE FOR ALL BUTTONS:'''
+
<syntaxhighlight>
 
+
procedure TForm1.FormCreate(Sender: TObject);
    procedure TForm1.FormCreate(Sender: TObject);
+
var
    var
+
  I: Integer;
        I: Integer;
+
begin
    begin
+
  for I := 0 to Form1.ControlCount - 1 do begin
        for I := 0 to Form1.ControlCount - 1 do
+
    if (Form1.Controls[I].ClassType = TButton) then Form1.Controls[I].Height := 22;
        begin
+
  end;
            if (Form1.Controls[I].ClassType = TButton) then
+
end;
                Form1.Controls[I].Height := 22;
+
</syntaxhighlight>
        end;
 
    end;
 
  
 
[[Category:Mac OS X]]
 
[[Category:Mac OS X]]
 
[[Category:Platform-sensitive development]]
 
[[Category:Platform-sensitive development]]

Revision as of 20:12, 24 May 2018

Stock-dialog-warning.svg

This article applies to Mac OS X only.

See also: Multiplatform Programming Guide

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;