Skip to main content

DesktopCommand

Enum DesktopCommand 

Source
pub enum DesktopCommand {
Show 17 variants OpenWindow(Box<OpenWindow>), SetAttributes(Box<WindowAttributes>), Request(WindowRequest), Quit, Restart, SetQuitMode(QuitMode), SetQuitOnRequest(bool), SetQuitRequestOptions(QuitRequestOptions), CancelQuitRequest, SetMenu(Option<Arc<[MenuItem]>>), SetMenuBar(MenuBarMode), PerformMenuRole(MenuRole), SetMenuLabels(Box<MenuLabels>), PopupMenu { items: Arc<[MenuItem]>, at: Option<Point<Points>>, }, SetTray(Option<Tray>), RegisterGlobalShortcut { id: u32, shortcut: Shortcut, }, UnregisterGlobalShortcut(u32),
}
Expand description

A desktop command, on a window’s root node (the root for the main window and what is the app’s: menus, the tray, global shortcuts).

Variants§

§

OpenWindow(Box<OpenWindow>)

Shows the dialog root the command is addressed to in a window of its own, until the node is removed. Sent before the node is inserted; a platform without windows of its own ignores it (the runtime does not send it there).

§

SetAttributes(Box<WindowAttributes>)

The window’s attributes that changed since the last commit (the fields set; one command per window and commit).

§

Request(WindowRequest)

A request to the window.

§

Quit

Quits the app, as its quit menu role does: the app ends without a per-window close path, also when closing the window would leave it running (a window kept hidden, a tray icon). A view embedded in another app leaves the app’s lifecycle to that app.

§

Restart

Quits the app as DesktopCommand::Quit does, then starts it again with the same arguments once this process has exited ([crate::restart]). A view embedded in another app leaves the app’s lifecycle to that app: nothing happens there.

§

SetQuitMode(QuitMode)

When the app quits if its last window closes (the mode Application.setQuitMode sets; "platform" defaults to it on Windows and Linux, not macOS). The core sends DesktopCommand::Quit on the root when the last window goes and the mode quits there.

§

SetQuitOnRequest(bool)

Whether the user’s quit requests quit the app: its Quit item and the platform’s quit key (Command-Q, Ctrl+Q). false while the app listens to them (crate::element::desktop::on_quit_request): the platform reports them on the root (WindowEvent::QuitRequest) instead, and the app sends DesktopCommand::Quit when it is ready. The system ending the app quits either way by default; macOS and Windows can include it with DesktopCommand::SetQuitRequestOptions. Sent when it changes; true until the first. On the web, while it is false, the user leaving the page is the request.

§

SetQuitRequestOptions(QuitRequestOptions)

Sets the additional quit request sources (macOS; system on Windows and, with a session manager, Linux too). Both default to false. Other platforms ignore this command.

§

CancelQuitRequest

Cancels a pending quit request on macOS, Windows and Linux, including the system’s logout or shutdown. Nothing happens without a pending request.

§

SetMenu(Option<Arc<[MenuItem]>>)

The application menu (macOS’s menu bar, the window’s menu bar on Windows and Linux; not shown there while the title bar is hidden, its shortcuts still work); None restores the platform’s default.

§

SetMenuBar(MenuBarMode)

When the menu bar the window draws for the application menu shows.

§

PerformMenuRole(MenuRole)

Performs a menu role as the application menu’s item of that role does (Menu.perform): an edit role acts on the focused view, a window role on the focused window. For menus the app draws itself.

§

SetMenuLabels(Box<MenuLabels>)

The core translated the labels of NSH’s menus for the language the app shows. Native backends update their menus at once.

§

PopupMenu

Shows a context menu at at (root coordinates, points) or at the pointer.

Fields

§items: Arc<[MenuItem]>

Its items.

§at: Option<Point<Points>>

Where its top left corner goes.

§

SetTray(Option<Tray>)

Shows the app’s icon in the system tray (the notification area on Windows, the menu bar’s status items on macOS, a StatusNotifierItem on Linux), or changes it; None removes it. One per app: the last window’s wins.

§

RegisterGlobalShortcut

Registers shortcut system-wide, whichever app has the keyboard: the root’s crate::EventKind::Menu reports id with registered (whether the system took it), then id alone at each press.

Fields

§id: u32

Reported at each press (not 0).

§shortcut: Shortcut

The keystroke.

§

UnregisterGlobalShortcut(u32)

Gives back the global shortcut registered as id.

Trait Implementations§

Source§

impl Clone for DesktopCommand

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DesktopCommand

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for DesktopCommand

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DesktopCommand

Auto Trait Implementations§

§

impl !RefUnwindSafe for DesktopCommand

§

impl !UnwindSafe for DesktopCommand

§

impl Forget for DesktopCommand

§

impl Freeze for DesktopCommand
where *const OpenWindow is !null: Freeze, PhantomData<OpenWindow>: Freeze, *const WindowAttributes is !null: Freeze, PhantomData<WindowAttributes>: Freeze, *const ArcInner<[MenuItem]> is !null: Freeze, PhantomData<ArcInner<[MenuItem]>>: Freeze, *const MenuLabels is !null: Freeze, PhantomData<MenuLabels>: Freeze, *const ArcInner<str> is !null: Freeze, PhantomData<ArcInner<str>>: Freeze, *const ArcInner<dyn AsRef<[u8]> + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn AsRef<[u8]> + Sync + Send>>: Freeze, *const ArcInner<Rgba> is !null: Freeze, PhantomData<ArcInner<Rgba>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<TrayTitleRun>: Freeze,

§

impl Move for DesktopCommand

§

impl Send for DesktopCommand
where BoxRaw<OpenWindow>: Send, BoxRaw<WindowAttributes>: Send, Arc<[MenuItem]>: Send, BoxRaw<MenuLabels>: Send, Arc<str>: Send, Arc<dyn AsRef<[u8]> + Sync + Send>: Send, Arc<Rgba>: Send, RawVecInner: Send,

§

impl Sync for DesktopCommand
where BoxRaw<OpenWindow>: Sync, BoxRaw<WindowAttributes>: Sync, Arc<[MenuItem]>: Sync, BoxRaw<MenuLabels>: Sync, Arc<str>: Sync, Arc<dyn AsRef<[u8]> + Sync + Send>: Sync, Arc<Rgba>: Sync, RawVecInner: Sync,

§

impl Unpin for DesktopCommand

§

impl UnsafeUnpin for DesktopCommand

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.