Page 1 of 1

Lazarus – macOS – Set Dock Icon text and bouncing Dock Icon

Lazarus – macOS – Set Dock Icon text and bouncing Dock Icon

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.
Examples: "MacOS X - Your question", "MS Word - Your Tip or Trick".

Please note that switching to another language when reading a post will not work!
Posts will not have a translated counterpart.

RSS Feed

Home Forums Software Development Delphi, Lazarus, Free Pascal Lazarus – macOS – Set Dock Icon text and bouncing Dock Icon

Viewing 1 post (of 1 total)
  • Author
  • 11857


    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:


    2. Bounce until the application (form) gets focus (only works when the application does not have focus!):


    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:


    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!


    The tekst is removed again with:

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.