-
Notifications
You must be signed in to change notification settings - Fork 333
Following host OS UX UI
In order to tailor UX-UI based on the platform running an application (MacOS or Windows, other platforms being seen as MacOS), a new CPApplication
method is declared : setOSBehavior
.
- (void)setOSBehavior:(CPApplicationOSBehavior)anOSBehavior
You can pass two values :
-
CPApplicationLegacyOSBehavior
: this is the default value and represents usual behavior (platform independence) ; -
CPApplicationFollowOSBehavior
: this permits to tailor UX-UI based on the platform running the application.
Right now, only windows buttons (close, minify, zoom) use this parameter. If set to CPApplicationFollowOSBehavior
, when running on Windows, buttons will show on the top right of the window (instead of top left) and will have a Windows-like look & feel (when using Aristo3 theme).
Legacy behavior:
Follow behavior (on a Windows machine):
During application start (after loading default theme and before loading the main Cib), the application will try to determine the value of OSBehavior
:
- Default value is
CPApplicationLegacyOSBehavior
; - If a standard user default named
CPApplicationOSBehavior
is found, its value (which must be@"CPApplicationLegacyOSBehavior"
or@"CPApplicationFollowOSBehavior"
) will be used ; - Else, if the
Info.plist
file of the application contains a key namedCPApplicationOSBehavior
, of typeString
, its value (which must beCPApplicationLegacyOSBehavior
orCPApplicationFollowOSBehavior
) will be used.
When called with a valid CPApplicationOSBehavior value, setOSBehavior
will post the CPApplicationOSBehaviorDidChangeNotification
notification.
AppKit widgets can then register as observers of this notification in order to adapt their UX-UI regarding the value of [CPApp OSBehavior]
.
The utility method [CPApp shouldMimicWindows]
(boolean) can be used in your code. It will return YES
if OSBehavior
is equal to CPApplicationFollowOSBehavior
and if your application is running on a Windows platform.
For development testing purpose, you can add a boolean flag CPApplicationSimulateWindowsOS
to the Info.plist of your application (this should be removed in your release). If set to YES
, when computing the value of [CPApp shouldMimicWindows]
, CPApplication will consider that your application runs on a Windows platform (whatever the real platform).