pub trait WindowHandler<UserEventType = ()> {
Show 15 methods fn on_start(
        &mut self,
        helper: &mut WindowHelper<UserEventType>,
        info: WindowStartupInfo
    ) { ... } fn on_user_event(
        &mut self,
        helper: &mut WindowHelper<UserEventType>,
        user_event: UserEventType
    ) { ... } fn on_resize(
        &mut self,
        helper: &mut WindowHelper<UserEventType>,
        size_pixels: UVec2
    ) { ... } fn on_mouse_grab_status_changed(
        &mut self,
        helper: &mut WindowHelper<UserEventType>,
        mouse_grabbed: bool
    ) { ... } fn on_fullscreen_status_changed(
        &mut self,
        helper: &mut WindowHelper<UserEventType>,
        fullscreen: bool
    ) { ... } fn on_scale_factor_changed(
        &mut self,
        helper: &mut WindowHelper<UserEventType>,
        scale_factor: f64
    ) { ... } fn on_draw(
        &mut self,
        helper: &mut WindowHelper<UserEventType>,
        graphics: &mut Graphics2D
    ) { ... } fn on_mouse_move(
        &mut self,
        helper: &mut WindowHelper<UserEventType>,
        position: Vec2
    ) { ... } fn on_mouse_button_down(
        &mut self,
        helper: &mut WindowHelper<UserEventType>,
        button: MouseButton
    ) { ... } fn on_mouse_button_up(
        &mut self,
        helper: &mut WindowHelper<UserEventType>,
        button: MouseButton
    ) { ... } fn on_mouse_wheel_scroll(
        &mut self,
        helper: &mut WindowHelper<UserEventType>,
        distance: MouseScrollDistance
    ) { ... } fn on_key_down(
        &mut self,
        helper: &mut WindowHelper<UserEventType>,
        virtual_key_code: Option<VirtualKeyCode>,
        scancode: KeyScancode
    ) { ... } fn on_key_up(
        &mut self,
        helper: &mut WindowHelper<UserEventType>,
        virtual_key_code: Option<VirtualKeyCode>,
        scancode: KeyScancode
    ) { ... } fn on_keyboard_char(
        &mut self,
        helper: &mut WindowHelper<UserEventType>,
        unicode_codepoint: char
    ) { ... } fn on_keyboard_modifiers_changed(
        &mut self,
        helper: &mut WindowHelper<UserEventType>,
        state: ModifiersState
    ) { ... }
}
Expand description

A set of callbacks for an active window. If a callback is not implemented, it will do nothing by default, so it is only necessary to implement the callbacks you actually need.

Provided Methods§

Invoked once when the window first starts.

Invoked when a user-defined event is received, allowing you to wake up the event loop to handle events from other threads.

See WindowHelper::create_user_event_sender.

Invoked when the window is resized.

Invoked if the mouse cursor becomes grabbed or un-grabbed. See WindowHelper::set_cursor_grab.

Note: mouse movement events will behave differently depending on the current cursor grabbing status.

Invoked if the window enters or exits fullscreen mode. See WindowHelper::set_fullscreen_mode.

Invoked when the window scale factor changes.

Invoked when the contents of the window needs to be redrawn.

It is possible to request a redraw from any callback using WindowHelper::request_redraw.

Invoked when the mouse changes position.

Normally, this provides the absolute position of the mouse in the window/canvas. However, if the mouse cursor is grabbed, this will instead provide the amount of relative movement since the last move event.

See WindowHandler::on_mouse_grab_status_changed.

Invoked when a mouse button is pressed.

Invoked when a mouse button is released.

Invoked when the mouse wheel moves.

Invoked when a keyboard key is pressed.

To detect when a character is typed, see the WindowHandler::on_keyboard_char callback.

Invoked when a keyboard key is released.

Invoked when a character is typed on the keyboard.

This is invoked in addition to the WindowHandler::on_key_up and WindowHandler::on_key_down callbacks.

Invoked when the state of the modifier keys has changed.

Implementors§