How do I add dock-icon badge and popupmenu support for lazarus apps in OSX?
I've tried googling around abit but I cannot find any help in using the badge feature of dock-icons on OSX aswell as getting access to the do开发者_JS百科ck icon menu? I guess I could change the dock icon during run to indicate something is up but it isn't as sleek ;)
This feature isn't implemented in LCL, so if you want to use it, you will have to use the relevant Cocoa framework directly. You can use ObjPas for that. Of course if you are up for writing an LCL implementation, that would be a better long term solution, as it could be made to work on Windows/Gnome later.
Ludicrous late ... but I bumped into this post, and found this post in the Lazarus Forum, which shows code how you can change the application icon in the dock while the application is running.
Hope it will be of use for someone looking for an answer to the same question, even though it's years after the post of the original question. (apologies if this is not appropriate)
uses
... MacOSAll ...
procedure TFrm_Main.FormCreate(Sender: TObject);
begin
...
FResPath := TrimFilename(ExtractFilePath(Application.ExeName) + PathDelim + 'Resource');
...
end;
procedure TFrm_Main.SomeEventWhenOverlay(SomeVar: Integer);
var
temp_ImagePath: String;
temp_CGDataProvider: CGDataProviderRef;
temp_Float32Ptr: Float32Ptr;
temp_CGImage: CGImageRef;
temp_CGContext: CGContextRef;
begin
temp_ImagePath := TrimFilename(FResPath + PathDelim + 'Image' + PathDelim + 'overlay_image.png'); // image must be same size as icon, if not, will be deformed
if (FileExists(temp_ImagePath)) then
begin
temp_CGDataProvider := CGDataProviderCreateWithFilename(PChar(temp_ImagePath));
temp_Float32Ptr := nil;
temp_CGImage := CGImageCreateWithPNGDataProvider(temp_CGDataProvider, temp_Float32Ptr, 1, kCGRenderingIntentDefault);
CGDataProviderRelease(temp_CGDataProvider);
// Draw image
temp_CGContext := BeginCGContextForApplicationDockTile;
//SetApplicationDockTileImage(temp_CGImage);
OverlayApplicationDockTileImage(temp_CGImage);
CGImageRelease(temp_CGImage);
EndCGContextForApplicationDockTile(temp_CGContext);
end;
end;
procedure TFrm_Main.SomeOtherEventWhenRestore();
begin
//This will not work if you use SetApplicationDockTileImage
RestoreApplicationDockTileImage;
end;
精彩评论