Tray
Tray item displayed in system notification area.
Header | #include "nativeui/tray.h" |
Namespace | namespace nu |
Type | class (RefCounted) |
Platform limitations:
- On Linux tray items are displayed as app indicators.
- On Linux there is no fallback when app indicators are not supported.
- On Linux app indicator can only show when it has menu attached.
- On Windows you have to explicitly remove the tray item on exit, otherwise a zombie icon would be left.
Constructors
Tray(scoped_refptr<Image> icon)
Create a tray item with icon
.
Parameters
scoped_refptr<Image>
icon
macOS
Tray(const std::string& title)Create a tray item with only title
.
Parameters
const std::string&
title
Methods
void Remove()
Remove the tray item.
macOS Windows
RectF GetBounds() constReturn the position and size of the tray item.
Return
RectF
macOS Linux
void SetTitle(const std::string& title)Set title to be displayed aside item's icon.
Parameters
const std::string&
title
void SetImage(scoped_refptr<Image> icon)
Set the icon
of tray item.
Parameters
scoped_refptr<Image>
icon
macOS
void SetPressedImage(scoped_refptr<Image> image)Set the image
to show when tray item is pressed.
Parameters
scoped_refptr<Image>
image
void SetMenu(scoped_refptr<Menu> menu)
Set the menu attached with the tray item.
On most platforms the menu will show when clicking on the icon, while on Windows the menu will only show when when right-clicking on the icon.
Parameters
scoped_refptr<Menu>
menu
Menu* GetMenu() const
Return the menu attached.
Return
Menu*
Events
macOS Windows
void on_click(Tray* self)Emitted when the tray item is clicked.
Parameters
Tray*
self