Difference between revisions of "Cocoa Internals/Buttons"
m (→Buttons Map) |
m (→Buttons Map) |
||
Line 25: | Line 25: | ||
TBitBtn could also be used as a replacement for TButton. I.e. TBitBtn could be a "Default" button on a modal dialog. | TBitBtn could also be used as a replacement for TButton. I.e. TBitBtn could be a "Default" button on a modal dialog. | ||
And there's no corresponding replacement for that in macOS | And there's no corresponding replacement for that in macOS | ||
+ | |- | ||
+ | | TSpeedButton | ||
+ | | | ||
+ | | This is not an actual control button, it's LCL-drawn button. | ||
+ | |||
+ | todo: no themes API customdrawn controls used? | ||
+ | |||
+ | The font used for caption of the button is [https://developer.apple.com/documentation/appkit/nsfont/1530094-systemfontofsize?language=objc NSFont.systemFontOfSize] | ||
|} | |} | ||
Revision as of 07:35, 17 December 2017
Buttons Map
Despite of being a very basic control, buttons are complicated topic on macOS.
LCL Button | OSX Button / Style | Description |
---|---|---|
TButton | Push Button
NSRoundedBezelStyle |
Per macOS design guidelines, Push buttons should only have labels on them, and no Icons. This is exactly, how LCL TButton behaves.
The biggest issue, is that macOS Push Buttons are of the fixed height. While LCL buttons can be any height. The approach similar to Carbon implementation could be used - after a certain hight the button changes its bezel. currently r56760 it's disabled |
TBitBtn | Image Button
NSRegularSquareBezelStyle |
TBitBtn is a button that could hold an image in it's body.
The closest (not deprecated) to such tasks is NSRegularSquareBezelStyle in macOS TBitBtn could also be used as a replacement for TButton. I.e. TBitBtn could be a "Default" button on a modal dialog. And there's no corresponding replacement for that in macOS |
TSpeedButton | This is not an actual control button, it's LCL-drawn button.
todo: no themes API customdrawn controls used? The font used for caption of the button is NSFont.systemFontOfSize |
Textured styles
There are number of styles for buttons named "Textured" (i.e. NSTexturedRoundedBezelStyle, NSTexturedSquareBezelStyle). These buttons a designed to be used in "Metal" aka "Textured" style windows, and Window Frames (borders/tool bars) Thus these styles should not be used.
Cocoa vs Carbon
Styles are for Cocoa and Carbon are a little bit different for buttons. For example "default" height of Push button is different between Cocoa and Carbon. Thus a UI designed for Carbon might not look good for Cocoa.
This is a problem of buttons only, other rectangular controls (textbox, listbox) doesn't experience such problem.
Smart Style Selection
In macOS guidelines, style of a button should be used depending on the placement/usage of a button.
In LCL design, there's not such thing as "style". It's presumed that the button would look the same, no matter where on the screen it's or what the button's parent. (It's not uncommon to design the interface in such a way).
Thus some LCLs might look foreign to macOS native applications, just because wrong button styles are used. I.e. a push button is used in a tool bar.
There are a few approaches what could be used:
- adding new TxxxButton classes into LCL (quite wasteful, and might not be applicable for other OSes)
- adding a style property to TBitBtn button (non delphi compatible)
- changes styles within Cocoa widgetset, automatically, depending on the placement of the button.
See Also
- Cocoa Internals
- https://developer.apple.com/macos/human-interface-guidelines/buttons/checkboxes/ - the official guide to macOS button styles
- https://developer.apple.com/documentation/appkit/nsbezelstyle?language=objc - bezel constants descriptions
- https://mackuba.eu/2014/10/06/a-guide-to-nsbutton-styles/ - a non-official guide to macOS button styles