Skip to content

Commit 693a083

Browse files
Takoooooogrokys
authored andcommitted
Add support for setting tooltip text for TrayIcons (#12948)
1 parent 58ef8ed commit 693a083

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

native/Avalonia.Native/src/OSX/trayicon.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class AvnTrayIcon : public ComSingleObject<IAvnTrayIcon, &IID_IAvnTrayIcon>
2828
virtual HRESULT SetMenu (IAvnMenu* menu) override;
2929

3030
virtual HRESULT SetIsVisible (bool isVisible) override;
31+
32+
virtual HRESULT SetToolTipText (char* text) override;
3133
};
3234

3335
#endif /* trayicon_h */

native/Avalonia.Native/src/OSX/trayicon.mm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,18 @@
8383

8484
return S_OK;
8585
}
86+
87+
HRESULT AvnTrayIcon::SetToolTipText(char* text)
88+
{
89+
START_COM_CALL;
90+
91+
@autoreleasepool
92+
{
93+
if (text != nullptr)
94+
{
95+
[[_native button] setToolTip:[NSString stringWithUTF8String:(const char*)text]];
96+
}
97+
}
98+
99+
return S_OK;
100+
}

src/Avalonia.Native/TrayIconImpl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public unsafe void SetIcon(IWindowIconImpl? icon)
5050

5151
public void SetToolTipText(string? text)
5252
{
53-
// NOP
53+
_native.SetToolTipText(text);
5454
}
5555

5656
public void SetIsVisible(bool visible)

src/Avalonia.Native/avn.idl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,7 @@ interface IAvnTrayIcon : IUnknown
809809
HRESULT SetIcon(void* data, size_t length);
810810
HRESULT SetMenu(IAvnMenu* menu);
811811
HRESULT SetIsVisible(bool isVisible);
812+
HRESULT SetToolTipText(char* text);
812813
}
813814

814815
[uuid(a7724dc1-cf6b-4fa8-9d23-228bf2593edc)]

0 commit comments

Comments
 (0)