Sign in Join
Wiki copytemporary

macOS extensions: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11*(macOS only)*
22
33The package is intended to provide additional macOS **Cocoa** specific features.
44
55**Note**: It's expected that those features will not work on any other system or as well as for deprecated **Carbon** API on macOS. However, it's expected that a project using the package would still succeffully compile and run on any other target.
66
77## General Info
88
99Author: Dmitry 'skalogryz' Boyarintsev
1010
1111License: [modified](http://svn.freepascal.org/svn/lazarus/trunk/COPYING.modifiedLGPL) [LGPL](http://svn.freepascal.org/svn/lazarus/trunk/COPYING.LGPL) (same as the FPC RTL and the Lazarus LCL). You can contact the author if the modified LGPL doesn't work with your project licensing.
1212
1313Repository: <https://github.com/skalogryz/macosext>
1414
1515## Extensions
1616
1717After installation a new "macOS" tab is added to the components palette. All additional components are available in this tab:
1818
1919![](/wiki-images/a/a1/Macosext_mainbar.PNG)
2020
2121### MacOSFormProp
2222
2323The component is introduced to control MacOS NSWindow specific attributes and features, not available via LCL API.
2424
2525#### Appearance
2626
2727![](/wiki-images/5/53/Macosformprop_apppropeditor.PNG) [NSAppearance](https://developer.apple.com/documentation/appkit/nsappearance?language=objc) class was introduced in macOS 10.9 for the first time. It controls window appearance options. The fact that it's per window configuration makes it different from Themes - that's system wide configuration.
2828
2929**Appearance** property of TmacOSFormProp component is used to adjust the appearance.
3030
3131Apple suggests that there are 3 appearance styles currently available in the system:
3232
33-`* NSAppearanceNameAqua`\
34-`* NSAppearanceNameVibrantDark`\
35-`* NSAppearanceNameVibrantLight`
33+```text
34+* NSAppearanceNameAqua
35+* NSAppearanceNameVibrantDark
36+* NSAppearanceNameVibrantLight
37+```
3638
3739The property itself is a string. It is not restricted to these 3 options only. It's **case-sensitive** name of the appearance [as provided by macOS](https://developer.apple.com/documentation/appkit/nsappearance/standard_appearances?language=objc).
3840
3941The value of the property can be changed in design time as well as run-time. As soon as the value is changed, it's expected that the appearance of the form, is changed.
4042
4143**Note:** if the form that's hosts TmacOSFormProp is embedded into another form, then the behavior is not defined. However, it's expected the parent form appearance would change.
4244
4345Using TmacOSFormProp is not desired on any component other than form. I.e. it's possible to use it on a frame, but in that case, the appearance of the hosting would be changed.
4446
4547In case multiple TmacOSFormProp are used, the later action would be used as preference. Multiple TmacOSFormProp are not desired for use, and might forbidden in future versions.
4648
4749The implementation is checking for the presence of NSAppearance class dynamically. Thus, if the code is launched on an earlier version of macOS, it would still be able to run, even though will not do anything.
4850
4951This is how the default **Aqua** style might look like:
5052
5153![](/wiki-images/f/f1/Macosformprop_aqua.PNG)
5254
5355This is how the **Dark** style might look like:
5456
5557![](/wiki-images/3/38/Macosformprop_dark.PNG)
5658
5759(Note that some controls are not affected by Appearance - TMemo. This is macOS default behavior and expected result)
5860
5961The actual style look as well style availability depends on a certain macOS version, and might change overtime at Apple's decision
6062
6163You can refer to **appearance** sample application.
6264
6365#### DocEdited
6466
6567The property indicates if the window should reflect the document as "edited" (true) or not (false).
6668
6769In systems other than macOS, a change in a document is typically indicated by adding asterisk character to the end of the window caption.
6870
6971macOS provides a special UI behavior in this case.
7072
7173![](/wiki-images/a/af/Macosformprop_editted.png)
7274
7375### MacOSUIProc
7476
7577The unit provides additional macOS UI utilities.
7678
7779#### PromptUserSheet
7880
7981The function shows a simple user dialog as a sheet (sheets are modal to a window, not to the entire application). Does nothing on any other platform. (todo - it's possible to implement it as modal forms). Parameters are similar (while not identical) to PromptUser function:
8082
8183- DialogCaption: string
8284- DialogMessage: string
8385- DialogType - type of the dialog. idDialogXXX (declared at LCLType)
8486- Buttons - array of button types that should be shown (refer to idButtonXXX list at LCLType)
8587- DefaultIndex - default button index
8688- AParentForm: TCustomForm - a form where the sheet should be shown
8789
8890## To be Implemented
8991
9092- NSToolbar support - TToolbar doesn't correspond to macOS UI guidelines
9193
9294## See Also
9395
9496- [[Cocoa Interface]] - LCL implementation of cocoa widgetset
9597- [NSAppearance](https://developer.apple.com/documentation/appkit/nsappearance?language=objc) - NSAppearance class reference in Apple documentation
9698
9799---
98100*From the Free Pascal wiki, page "macOS extensions", as it stood on 2019-12-14 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
99101Category: Cocoa
100102Category: Components
101103Category: macOS

Back to history