Trait EventLoopBuilderExtMacOS

Source
pub trait EventLoopBuilderExtMacOS {
    // Required methods
    fn with_activation_policy(
        &mut self,
        activation_policy: ActivationPolicy,
    ) -> &mut Self;
    fn with_default_menu(&mut self, enable: bool) -> &mut Self;
    fn with_activate_ignoring_other_apps(&mut self, ignore: bool) -> &mut Self;
}
Available on macos_platform only.

Required Methods§

Source

fn with_activation_policy( &mut self, activation_policy: ActivationPolicy, ) -> &mut Self

Sets the activation policy for the application. If used, this will override any relevant settings provided in the package manifest. For instance, with_activation_policy(ActivationPolicy::Regular) will prevent the application from running as an “agent”, even if LSUIElement is set to true.

If unused, the Winit will honor the package manifest.

§Example

Set the activation policy to “accessory”.

use winit::event_loop::EventLoopBuilder;
#[cfg(target_os = "macos")]
use winit::platform::macos::{ActivationPolicy, EventLoopBuilderExtMacOS};

let mut builder = EventLoopBuilder::new();
#[cfg(target_os = "macos")]
builder.with_activation_policy(ActivationPolicy::Accessory);
let event_loop = builder.build();
Source

fn with_default_menu(&mut self, enable: bool) -> &mut Self

Used to control whether a default menubar menu is created.

Menu creation is enabled by default.

§Example

Disable creating a default menubar.

use winit::event_loop::EventLoopBuilder;
#[cfg(target_os = "macos")]
use winit::platform::macos::EventLoopBuilderExtMacOS;

let mut builder = EventLoopBuilder::new();
#[cfg(target_os = "macos")]
builder.with_default_menu(false);
let event_loop = builder.build();
Source

fn with_activate_ignoring_other_apps(&mut self, ignore: bool) -> &mut Self

Used to prevent the application from automatically activating when launched if another application is already active.

The default behavior is to ignore other applications and activate when launched.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§