So one of the nice things of macOS is the Dock.
From an application perspective, the bouncing icon asking for the attention of the user is cool, and having a badge (a number or % or whatever you want) tagged to the dock icon helps with giving the user feedback even when the application is not visible.
So how do we do this in Lazarus Pascal?
I found this post in the Lazarus Forum and after some tinkering managed to get both to work in a very easy way.
First of all, the compiler needs to be set in ObjectiveC1 mode. You can place this somewhere at the top of your unit.
{$modeswitch ObjectiveC1}
Next we will need the unit MacOSAll and CocoaAll.
uses ... ,MacOSAll, CocoaAll ...;
Bouncing Dock Icon ...
1. Bounce once:
NSApplication.sharedApplication.requestUserAttention(NSInformationalRequest);
2. Bounce until the application (form) gets focus (only works when the application does not have focus!):
NSApplication.sharedApplication.requestUserAttention(NSCriticalRequest);
3. Manually stop the bouncing:
For this we will need to store the request ID, so we can reference it when asking for the bouncing to stop.
Because of this we start the bouncing as such:
AttentionRequestID : NSInteger;
...
AttentionRequestID := NSApplication.sharedApplication.requestUserAttention(NSCriticalRequest);
...
and later on we stop it with:
NSApplication.sharedApplication.cancelUserAttentionRequest(AttentionRequestID);
Add Text to Dock Icon (eg. a number or a percentage) ...
In this example I set the text to "100%", but this can be anything - just keep it short, there is not much space!
NSApplication.sharedApplication.dockTile.setBadgeLabel(NSStr(Pchar('100%')));
The tekst is removed again with:
NSApplication.sharedApplication.dockTile.setBadgeLabel(nil);