Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Commit

Permalink
More stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
drasticactions committed Dec 26, 2021
1 parent 432206a commit 45fe82b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions DrasticMaui/Tray/TrayService.MacCatalyst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Runtime.InteropServices;
using CoreFoundation;
using Foundation;
using Microsoft.Maui.Platform;
using ObjCRuntime;

namespace DrasticMaui.Tray
Expand All @@ -16,7 +17,7 @@ public partial class TrayService : NSObject
private NSObject? statusBarObj;
private NSObject? statusBarItem;
private NSObject? statusBarButton;
private NSObject? statusBarImage;
private AppKit.NSImage? statusBarImage;
private NSObject? popoverObj;
private NSObject? nsViewControllerObj;
private NSObject? nsViewController;
Expand Down Expand Up @@ -51,7 +52,7 @@ public void SetupTrayIcon()
}

this.statusBarButton = Runtime.GetNSObject(IntPtr_objc_msgSend(this.statusBarItem.Handle, Selector.GetHandle("button")));
this.statusBarImage = Runtime.GetNSObject(IntPtr_objc_msgSend(ObjCRuntime.Class.GetHandle("NSImage"), Selector.GetHandle("alloc")));
this.statusBarImage = Runtime.GetNSObject<AppKit.NSImage>(IntPtr_objc_msgSend(ObjCRuntime.Class.GetHandle("NSImage"), Selector.GetHandle("alloc")));

if (this.statusBarImage is null)
{
Expand All @@ -73,6 +74,8 @@ public void SetupTrayIcon()
void_objc_msgSend_IntPtr(this.statusBarButton.Handle, Selector.GetHandle("setImage:"), this.statusBarImage.Handle);
void_objc_msgSend_bool(nsImagePtr, Selector.GetHandle("setTemplate:"), true);

this.statusBarImage.Size = new CoreGraphics.CGSize(32, 32);

// Handle click
void_objc_msgSend_IntPtr(this.statusBarButton.Handle, Selector.GetHandle("setTarget:"), this.Handle);
void_objc_msgSend_IntPtr(this.statusBarButton.Handle, Selector.GetHandle("setAction:"), new Selector("handleButtonClick:").Handle);
Expand Down

0 comments on commit 45fe82b

Please sign in to comment.