Skip to main content

Application

Trait Application 

Source
pub trait Application: Send + 'static {
    // Required methods
    fn initialize(&mut self, ctx: &Context, event_loop: &ActiveEventLoop);
    fn window_event(
        &mut self,
        ctx: &Context,
        event_loop: &ActiveEventLoop,
        window_id: WindowId,
        event: WindowEvent,
    );

    // Provided methods
    fn device_event(
        &mut self,
        ctx: &Context,
        event_loop: &ActiveEventLoop,
        device_id: DeviceId,
        event: DeviceEvent,
    ) { ... }
    fn update(&mut self, ctx: &Context, event_loop: &ActiveEventLoop) { ... }
    fn exiting(&mut self, ctx: &Context) { ... }
}
Expand description

应用程序生命周期 trait(桌面端)。

上层 crate(如 iris-app)实现此 trait 来定义应用生命周期。

Required Methods§

Source

fn initialize(&mut self, ctx: &Context, event_loop: &ActiveEventLoop)

当事件循环启动、窗口即将创建时调用。

Source

fn window_event( &mut self, ctx: &Context, event_loop: &ActiveEventLoop, window_id: WindowId, event: WindowEvent, )

窗口事件回调。

Provided Methods§

Source

fn device_event( &mut self, ctx: &Context, event_loop: &ActiveEventLoop, device_id: DeviceId, event: DeviceEvent, )

设备/系统事件回调(如屏幕 DPI 变化、时间戳等)。

Source

fn update(&mut self, ctx: &Context, event_loop: &ActiveEventLoop)

每帧更新回调(AboutToWait 事件)。

Source

fn exiting(&mut self, ctx: &Context)

当应用即将退出时调用。

Implementors§