View Issue Details

IDProjectCategoryView StatusLast Update
0031185LazarusWidgetsetpublic2017-05-22 11:31
ReporterAlexey Tor.Assigned ToFelipe Monteiro de Carvalho 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionnot fixable 
PlatformOSX 10.8OSOS Version
Product Version1.6.3 (SVN)Product Build 
Target VersionFixed in Version 
Summary0031185: Cocoa: weird button height, for AutoSize off
DescriptionIf button has Autosize off, and normal height (abt 22-23 pixels)
it's shown as tiny 4-5 pixel tall button
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetCocoa
Attached Files

Activities

Alexey Tor.

2017-01-02 14:42

reporter  

tst_cocoa_btn.zip (3,484 bytes)

Alexey Tor.

2017-01-02 14:42

reporter  

cocoa-crap-btn (481,462 bytes)

Alexey Tor.

2017-01-02 14:42

reporter  

cocoa-crap-btn.png (481,462 bytes)

Felipe Monteiro de Carvalho

2017-01-05 17:42

developer   ~0097313

The button has 17 pixels tall, just enlarge the image and count the pixels.

IMHO this is just the native behavior, the Cocoa buttons have a large border so the useful area is smaller than in other widgetsets.

Felipe Monteiro de Carvalho

2017-01-05 17:42

developer   ~0097314

Use TCDButton if you want a non-native buttons: http://wiki.freepascal.org/Lazarus_Custom_Drawn_Controls#TCDButton

Felipe Monteiro de Carvalho

2017-01-05 17:43

developer   ~0097315

Just to be more clear: We don't do anything to break the button. We just pass the size you selected to Cocoa. Cocoa breaks it. So it is the native expected behavior.

Alexey Tor.

2017-01-06 06:55

reporter   ~0097328

Last edited: 2017-01-06 06:56

View 3 revisions

I need native buttons. Pls tell: how to make native btn, with custom width
(e.g. width 300 pix)? And usual height.
It is issue: i cannot do.

Felipe Monteiro de Carvalho

2017-01-18 15:41

developer   ~0097575

This works good if you create the button during run-time, for example during OnCreate of the form:

procedure TForm1.FormCreate(Sender: TObject);
var
  lWidth, lHeight: integer;
  NewButton: TButton;
begin
  NewButton := TButton.Create(Self);
  NewButton.AutoSize := False;
  NewButton.GetPreferredSize(lWidth, lHeight);
  NewButton.Height := lHeight;
  NewButton.Width := 300;
  NewButton.Top := 100;
  NewButton.Left := 100;
  NewButton.Parent := Self;
end;

Alexey Tor.

2017-01-18 16:47

reporter   ~0097577

Last edited: 2017-01-18 16:47

View 2 revisions

Hm. will test this method. But what about design time forms, the designed buttons (if not Autosize) look bad on cocoa (while OK in carbon). This is a issue.

Felipe Monteiro de Carvalho

2017-05-19 22:10

developer   ~0100510

It looks like we will need to introduce this:
AutoSizeMode = (amBoth, amHeight, amWidth)
To make what you want.

Alexey Tor.

2017-05-19 22:25

reporter   ~0100514

Can we make this enum for Cocoa WS only?
And set default, which fixes this issue.

Felipe Monteiro de Carvalho

2017-05-20 07:22

developer   ~0100522

We discussed in the mailling list, set in the Object Inspector:
1> Autosize=True
2> Constrains.MaxWidth = DesiredWidth
Constrains.MinWidth = DesiredWidth

does it work??

Felipe Monteiro de Carvalho

2017-05-20 08:08

developer   ~0100526

if this works good for everyone, I'll just make this a FAQ: http://wiki.freepascal.org/Cocoa_Interface#TButton_looks_too_small.21

Alexey Tor.

2017-05-20 09:12

reporter   ~0100530

Tried on my app:
1) design-time buttons: all ok size, hmm
2) runtime-created buttons: this bug
Workaround works for 2)
But fix still needed for many apps, and my app (workaround is not nice code)

Felipe Monteiro de Carvalho

2017-05-22 09:27

developer  

tst_cocoa_button.png (42,384 bytes)
tst_cocoa_button.png (42,384 bytes)

Felipe Monteiro de Carvalho

2017-05-22 09:31

developer   ~0100580

In my Mac OS X 10.10 the look is in the attached screenshot: tst_cocoa_button.png

Strange, maybe this is Mac OS X version dependent? Which version are you using?

Are you using the latest Lazarus from SVN?

We discussed in Lazarus-dev the following possibilities:

1> Add a new property AutosizeMode -> In this case you need to change all your buttons affected and set this property in all of them

2> You could set in Object Inspector AutoSize=True and Constrains for setting the width -> So preferred to option 1

3> You could delete from the lfm file the Height information for the button. If there is no height, the widgetset default will be used. Does this work for you? If not I can work on fixing the default value.

Alexey Tor.

2017-05-22 10:39

reporter   ~0100584

Yes, Lazarus latest trunk
OSX 10.8 - it may matter [I can test later on 10.11 if issue fixed]


Hmm. Maybe Cocoa WS is bad for OSX 10.8??? It is so? I need to test OSX 10.10 and then tell you.

Alexey Tor.

2017-05-22 10:43

reporter   ~0100585

Note:
- tried setting Btn.Constraints.MinHeight:= 21; dont help, btn still small.
- then Btn.Constraints.MinHeight:= 30; it helps for many buttons- they now look like CARBON btns with height=21.

Strange. Size 30 looks like Carbon size 21.

Alexey Tor.

2017-05-22 11:12

reporter   ~0100589

Last edited: 2017-05-22 11:13

View 2 revisions

On OSX 10.11 issue not present (btn 1-2 pixels smaller but OK)
Cocoa WS has issue for OSX 10.8 only.

Felipe Monteiro de Carvalho

2017-05-22 11:30

developer   ~0100591

The bug is in Mac OS X itself, it seams we have proven that. They fixed it either in 10.9 or in 10.10

Issue History

Date Modified Username Field Change
2017-01-02 14:42 Alexey Tor. New Issue
2017-01-02 14:42 Alexey Tor. File Added: tst_cocoa_btn.zip
2017-01-02 14:42 Alexey Tor. File Added: cocoa-crap-btn
2017-01-02 14:42 Alexey Tor. File Added: cocoa-crap-btn.png
2017-01-05 17:42 Felipe Monteiro de Carvalho Note Added: 0097313
2017-01-05 17:42 Felipe Monteiro de Carvalho LazTarget => -
2017-01-05 17:42 Felipe Monteiro de Carvalho Note Added: 0097314
2017-01-05 17:42 Felipe Monteiro de Carvalho Status new => resolved
2017-01-05 17:42 Felipe Monteiro de Carvalho Resolution open => not fixable
2017-01-05 17:42 Felipe Monteiro de Carvalho Assigned To => Felipe Monteiro de Carvalho
2017-01-05 17:43 Felipe Monteiro de Carvalho Note Added: 0097315
2017-01-06 06:55 Alexey Tor. Note Added: 0097328
2017-01-06 06:56 Alexey Tor. Note Edited: 0097328 View Revisions
2017-01-06 06:56 Alexey Tor. Note Edited: 0097328 View Revisions
2017-01-06 06:57 Alexey Tor. Status resolved => assigned
2017-01-06 06:57 Alexey Tor. Resolution not fixable => reopened
2017-01-18 15:41 Felipe Monteiro de Carvalho Note Added: 0097575
2017-01-18 16:47 Alexey Tor. Note Added: 0097577
2017-01-18 16:47 Alexey Tor. Note Edited: 0097577 View Revisions
2017-05-19 22:10 Felipe Monteiro de Carvalho Note Added: 0100510
2017-05-19 22:25 Alexey Tor. Note Added: 0100514
2017-05-20 07:22 Felipe Monteiro de Carvalho Note Added: 0100522
2017-05-20 08:08 Felipe Monteiro de Carvalho Note Added: 0100526
2017-05-20 09:12 Alexey Tor. Note Added: 0100530
2017-05-22 09:27 Felipe Monteiro de Carvalho File Added: tst_cocoa_button.png
2017-05-22 09:31 Felipe Monteiro de Carvalho Note Added: 0100580
2017-05-22 10:39 Alexey Tor. Note Added: 0100584
2017-05-22 10:43 Alexey Tor. Note Added: 0100585
2017-05-22 11:12 Alexey Tor. Note Added: 0100589
2017-05-22 11:13 Alexey Tor. Note Edited: 0100589 View Revisions
2017-05-22 11:30 Felipe Monteiro de Carvalho Note Added: 0100591
2017-05-22 11:31 Felipe Monteiro de Carvalho Status assigned => resolved
2017-05-22 11:31 Felipe Monteiro de Carvalho Resolution reopened => not fixable