如何在 OSX 中添加对 lazarus 应用程序的停靠图标徽章和弹出菜单支持?

发布于 2024-12-03 20:19:25 字数 98 浏览 1 评论 0原文

我尝试用谷歌搜索 abit,但在使用 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 dock icon menu? I guess I could change the dock icon during run to indicate something is up but it isn't as sleek ;)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱本泡沫多脆弱 2024-12-10 20:19:25

LCL中没有实现这个功能,所以如果你想使用它,你必须直接使用相关的Cocoa框架。您可以使用 ObjPas 来实现这一点。当然,如果您准备编写 LCL 实现,那么这将是一个更好的长期解决方案,因为稍后可以使其在 Windows/Gnome 上运行。

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.

﹉夏雨初晴づ 2024-12-10 20:19:25

可笑的晚了......但我偶然发现了这篇文章,并发现 Lazarus 论坛中的这篇文章,其中显示了如何在应用程序运行时更改 Dock 中的应用程序图标的代码。

希望它对寻找同一问题答案的人有用,即使是在原始问题发布多年之后。 (如果不合适请见谅)

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; 

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; 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文