pub struct TrayHandle { /* private fields */ }Expand description
A cheap, Clone + Send remote control for a running Tray.
Tray::run consumes the tray, so TrayHandle closes the gap: obtain one
with Tray::handle before run, move it to any thread, and post
commands the backend applies on its UI thread. Commands posted before the
run loop is live simply buffer and apply once it starts.
Implementations§
Source§impl TrayHandle
impl TrayHandle
Replace the menu shown on the next open (and repaint + refresh the accessibility tree live if the popup is already open).
Sourcepub fn set_tooltip(&self, tooltip: Option<impl Into<String>>)
pub fn set_tooltip(&self, tooltip: Option<impl Into<String>>)
Replace the tooltip / accessible name.
Sourcepub fn set_title(&self, title: Option<impl Into<String>>)
pub fn set_title(&self, title: Option<impl Into<String>>)
Replace the status-item text title (macOS menu-bar text, e.g. a live “45%”). A no-op on the drawn item on Windows/Linux.
Sourcepub fn set_visible(&self, visible: bool)
pub fn set_visible(&self, visible: bool)
Show or hide the tray status item.
Sourcepub fn shutdown(&self)
pub fn shutdown(&self)
Stop the tray: remove the OS status item and end its backend run loop (and
background thread, for a spawned tray). Best-effort and asynchronous — the
removal is applied on the backend’s UI thread. Used by the compat facade
to remove the icon when its TrayIcon is dropped, matching tray-icon.
Sourcepub fn set_theme(&self, theme: ThemeSource)
pub fn set_theme(&self, theme: ThemeSource)
Swap the live theme source (issue #45). Applied asynchronously on the
backend’s UI thread: the next popup open uses it, and any currently-open
popup is repainted — so a consumer can wire an in-menu “Preview theme”
submenu. See TrayCommand::SetTheme for the Linux SNI-tray caveat.
Sourcepub fn set_options(&self, options: MenuOptions)
pub fn set_options(&self, options: MenuOptions)
Swap the live MenuOptions wholesale — theme, width bounds, gutter
policy (issue #45). Applied like set_theme.
Sourcepub fn anchor_rect(&self) -> Option<LogicalRect>
pub fn anchor_rect(&self) -> Option<LogicalRect>
Best-effort cross-thread query for the tray icon’s current on-screen
rectangle (issue #48). The native, main-thread counterpart is
Tray::anchor_rect.
Posts a TrayCommand::QueryAnchorRect and waits briefly for the
backend to reply on its UI thread. Returns None if the run loop is not
yet live, the query times out, or the platform can’t report geometry
(the Linux SNI tray never can — its host owns the icon).
Trait Implementations§
Source§impl Clone for TrayHandle
impl Clone for TrayHandle
Source§fn clone(&self) -> TrayHandle
fn clone(&self) -> TrayHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more