Recent

Author Topic: Why are TButtons square?  (Read 21927 times)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Why are TButtons square?
« on: February 21, 2011, 06:05:02 pm »
Does anyone know why a TButton is square and flat? I found a bug report from 2009 (0012256) about square buttons in panels, but others were normal. The resolution of that issue was "It is Mac OS X issue, which we can't work around."

I'm finding all TButtons to be square though. I'm using OS X 10.6.5 and Lazarus 0.9.31. All TButtons are square using the Carbon widget set. They show up as standard rounded Aqua-style buttons in Qt.

Thanks, appreciate any thoughts.
“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)

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Why are TButtons square?
« Reply #1 on: February 21, 2011, 06:10:33 pm »
Just set the button Height properly:

http://web.me.com/macpgmr/ObjP/MacXPlatform_Part8.html#Buttons

Thanks.

-Phil

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Why are TButtons square?
« Reply #2 on: February 21, 2011, 06:34:35 pm »
That does the trick.

Thanks Phil!
“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)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Why are TButtons square?
« Reply #3 on: February 21, 2011, 07:22:30 pm »
I'm trying out the TButton options and have a few more questions.

I figured out that:
Setting Cancel = true allows pressing Esc to trigger the button action.
Setting TabOrder = 0 allows pressing Enter to trigger the action.

But don't understand:
Is there a way to highlight the default button? It is normally blue in OS X.
Is it possible to set the font size? I can't do it.
The default button font, I'm guessing Lucida Grande 12, is not centered correctly. It is several pixels too far up. Is there a way to center it or set the baseline?
“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)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Why are TButtons square?
« Reply #4 on: February 21, 2011, 07:37:13 pm »
Curiously, TBitBtn text is correctly centered vertically, TButton text is not.
“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)

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Why are TButtons square?
« Reply #5 on: February 21, 2011, 07:42:44 pm »
I'm trying out the TButton options and have a few more questions.

I figured out that:
Setting Cancel = true allows pressing Esc to trigger the button action.
Setting TabOrder = 0 allows pressing Enter to trigger the action.

But don't understand:
Is there a way to highlight the default button? It is normally blue in OS X.
I noticed that also, but haven't gotten around to looking at it.

Is it possible to set the font size? I can't do it.
The default button font, I'm guessing Lucida Grande 12, is not centered correctly. It is several pixels too far up. Is there a way to center it or set the baseline?

You should be able to set the font and font size.

I'm not sure what default font the Carbon widgetset uses, but setting the size correctly should center it okay. Are you talking about font Height or Size? In my app, Height=-13 vertically centers nicely when Lucida Grande is used - Lucida Grande is the one to use on Mac.

With my app, I run a script that converts the forms to eliminate some of the Lazarus non-standard behavior. It uses the DfmToLfm converter from the XDev Toollkit. This converter can also convert .lfm to .lfm too. The idea here, as I outlined in the article, is that you have two sets of forms. One set is what you design with, perhaps Windows if that's where you start. Then any time you make a change to a form there, you convert the forms to a different set used on Mac. They can have a different name if you want to keep them separate to avoid confusion.

So if you convert a form with the converter's -m -s switches, it will also do font substitution to make sure you're using Lucida Grande or other Mac fonts instead of typical MS Sans Serif or Arial that is often used on Windows.

http://web.me.com/macpgmr/XDev/XDevStatus.html

Thanks.

-Phil

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Why are TButtons square?
« Reply #6 on: February 21, 2011, 08:17:02 pm »
I had left the Font Name = default. If I change it to Name = Lucida Grande, I can indeed change the Height. Thanks.

Oddly, there is a difference in the vertical centering between TButton and TBitBtn. The text is vertically centered in a TBitBtn, but is too high in a TButton. I will just use a TBitBtn, but perhaps I should report it as a cosmetic bug.

I have tried setting TBitBtn.Default = true, and thought it might highlight the default button, but it doesn't. Maybe I should submit this as a request?

I'm still figuring out Lazarus and pretty sure I will eventually port three applications from REALbasic. I'm slowing migrating one now on OS X, but will need to figure out Windows as well if I am to do all three. Your article is helpful, and I'm trying to build in conditional compiles as I go. Maybe I will need multiple forms as well.

Thanks Phil
“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)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Why are TButtons square?
« Reply #7 on: February 21, 2011, 09:04:20 pm »
I just discovered that setting TBitBtn.Kind = bkOK results in a "OK" button glyph with a green checkmark. It would be nice if it were a blue Mac Aqua button, but maybe that is asking too much.
“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)

vvzh

  • Jr. Member
  • **
  • Posts: 58
Re: Why are TButtons square?
« Reply #8 on: February 21, 2011, 09:16:54 pm »
ShowGlyphMode is probably what you need to modify.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Why are TButtons square?
« Reply #9 on: February 21, 2011, 09:19:52 pm »
ShowGlyphMode is probably what you need to modify.

No, he doesn't want a glyph.

Did you read the link you cite? See the bottom comment about glyphs on Mac.

Thanks.

-Phil

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Why are TButtons square?
« Reply #10 on: February 21, 2011, 09:39:23 pm »
I just discovered that setting TBitBtn.Kind = bkOK results in a "OK" button glyph with a green checkmark. It would be nice if it were a blue Mac Aqua button, but maybe that is asking too much.

That's the garish old Delphi glyphs. I haven't seen apps that use them for years since that's not what Windows buttons look like either.

I'm not sure what the best solution ultimately is. Go ahead and file a bug report at least to document this. Perhaps all that's needed is for the Carbon widgetset to highlight the button that has Default = True.

Thanks.

-Phil

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Why are TButtons square?
« Reply #11 on: February 21, 2011, 09:50:04 pm »
Frederick,

What happens if you set a button's Default to True? Try it with both TButton and TBitBtn. I see this in the Carbon widgetset:

procedure TCarbonCustomButton.SetDefault(ADefault: Boolean);
begin
  OSError(
    SetControlData(ControlRef(Widget), kControlEntireControl,
      kControlPushButtonDefaultTag, SizeOf(Boolean), @ADefault),
    Self, 'SetDefault', SSetData);
end;

procedure TCarbonBitBtn.SetDefault(ADefault: Boolean);
begin
  // not supported
end;

So it seems like it should work with TButton but not with TBitBtn. If not, include your sample app that demonstrates the problem with your bug report.

Thanks.

-Phil

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Why are TButtons square?
« Reply #12 on: February 21, 2011, 10:28:37 pm »
That does work Phil. Thanks, I don't know why I didn't see that. Too long staring at the screen I guess.

Should that behavior be implemented in a TBitBtn?

That leaves just the minor cosmetic issue of vertical text centering. It is obvious if you create a TButton and a TBitBtn both with Height = 22 and identical text. A minor point perhaps, but it makes the TButtons look slightly odd, something users notice when evaluating a program.

« Last Edit: February 21, 2011, 10:30:39 pm by Frederick »
“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)

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Why are TButtons square?
« Reply #13 on: February 21, 2011, 10:48:24 pm »
That's probably why I wasn't seeing it, because I'm using TBitBtn.

It would be nice if TBitBtn supported the Default property. Not sure what that comment in the code means. Normally if a property is not supported, there will be an entry in the widgetset's issues.xml file, but I don't see anything about TBitBtn.Default in carbon's issues.xml.

You might want to post two different bug reports since the two issues are not related. That makes it easier for closing an issue if only one of them gets fixed.

Thanks.

-Phil

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Why are TButtons square?
« Reply #14 on: February 21, 2011, 10:54:28 pm »
Thanks Phil, I really appreciate your help. I will file two reports with sample code.

Regards,
Frederick
“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