Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Share:
Notifications
Clear all

[Solved] Lazarus Pascal - macOS - How to use the standard "About" dialog box that comes with Cocoa

1 Posts
1 Users
0 Reactions
12 Views
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 3011
Topic starter  

Cocoa has a build in function that automatically generates an About dialog box (documentation) and is super easy to use and implement.

An About dialog is generated on the fly and called like so (assuming your application has Info.plist file in the .app bundle);

...
Uses ..., CocoaAll, ... ;
...

// Opendialog like so:
NSApp.orderFrontStandardAboutPanel(Nil);

...

Example:

There are a few requirements and options to make it work nice which require a proper Info.plist file in your App bundle (myapplication.app/Contents/Info.plist)

 

Things that go in the Info.plist file:

CFBundleIconFile - defines the Icon you'll see in the About dialog. This is also the icon used by your application, typically located in the Resources dir (something like: myapplication.app/Contents/Resources/myapplication.icns). If not defined, a generic icon will be displayed.

CFBundleName - which represents the Application Name as shown in the About dialof.

CFBundleShortVersionString - holds the version number (Version 1.2.3), and if missing it will probably display something generic like "1.0".

CFBundleVersion - Displays the build number between parentheses.

NSHumanReadableCopyright - holds the copyright name, eg. John Doe.

 

Optional Credits text:

Optionally you can create a Credits file in myapplication.app/Contents/Resources/.
This can be html (Credits.html), or RichText (Credits.rtf or Credits.rtfd - see documentation).

The file needs to sit in the Resources directory and this file can be capital sensitive (depending on the filesystem your Mac uses).

The Credits.html file can even hold links (unlike RichText files), something simple like this:

<center>
<p>
Developed with <a href="https://www.lazarus-ide.org/">Lazarus Pascal</a>
</p>
<strong>Support</strong>
<p>
Contact us for support at<br>
<a href="https://www.tweaking4all.com">www.Tweaking4All.com</a>
</p>
</center>

Note that at runtime, you can close the dialog, change the HTML and re-open the dialog again to see the changes.
No need to recompile or restart your Lazarus application 😊 



   
ReplyQuote
Share: