Struct TrayMenuBuilder

Source
pub struct TrayMenuBuilder {
    pub options: Options,
    pub menu: Option<Menu>,
    pub tooltip: Option<String>,
    pub callback: Option<Callback<CallbackClosure<MouseEvent>>>,
}
Expand description

Provides a builder pattern for constructing a system tray menu for the application.

For usage example please refer to Examples

Fields§

§options: Options§menu: Option<Menu>§tooltip: Option<String>§callback: Option<Callback<CallbackClosure<MouseEvent>>>

Implementations§

Source§

impl TrayMenuBuilder

Source

pub fn new() -> Self

Source

pub fn set(self, key: &str, value: JsValue) -> Self

Source

pub fn title(self, title: &str) -> Self

Set the title of the tray.

NWJS Documentation

Source

pub fn tooltip(self, tooltip: &str) -> Self

Set the tooltip of the tray. tooltip shows when you hover the Tray with mouse.

Note: tooltip is showed on all three platforms. Should be set as Tray property rather from option object constructor.

NWJS Documentation

Source

pub fn icon(self, icon: &str) -> Self

Set the icon of the tray, icon must receive a path to your icon file. It can be a relative path which points to an icon in your app, or an absolute path pointing to a file in user’s system.

Mac OS X caveat: when used in notification context, png icon is not sized down like in windows notification area, it is rather displayed in 1:1 ratio.

NWJS Documentation

Source

pub fn alticon(self, alticon: &str) -> Self

(Mac) Set the alternate (active) tray icon.

NWJS Documentation

Source

pub fn icons_are_templates(self, icons_are_templates: bool) -> Self

(Mac) Set whether icon and alticon images are treated as “templates” (true by default). When the property is set to true the images are treated as “templates” and the system automatically ensures proper styling according to the various states of the status item (e.g. dark menu, light menu, etc.). Template images should consist only of black and clear colours and can use the alpha channel in the image to adjust the opacity of black content.

NWJS Documentation

Source

pub fn menu(self, menu: Menu) -> Self

Set the menu of the tray, menu will be showed when you click on the tray icon.

On Mac OS X the menu will be showed when you click on the tray (which is the only action available for tray icons on Mac OS X). On Windows and Linux, the menu will be showed when you single click on the tray with right mouse button, clicking with left mouse button sends the click event and does not show a menu.

In order to reduce differences from different platforms, setting menu property is the only way to bind a menu to tray, there’s no way to popup a menu with left mouse button click on Linux and Windows.

NWJS Documentation

Source

pub fn callback<F>(self, callback: F) -> Self
where F: FnMut(MouseEvent) -> Result<(), JsValue> + 'static,

The callback function when tray icon is clicked.

NWJS Documentation

Source

pub fn submenus(self, items: Vec<MenuItem>) -> Self

A submenu

NWJS Documentation

Source

pub fn build_impl( self, ) -> Result<(Tray, Option<Callback<CallbackClosure<MouseEvent>>>)>

Source

pub fn build(self) -> Result<Tray>

Source

pub fn finalize( self, ) -> Result<(Tray, Option<Callback<CallbackClosure<MouseEvent>>>)>

Trait Implementations§

Source§

impl Default for TrayMenuBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V