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

A trait analogous to speedy2d::window::WindowHandler, but with the addition of a egui_ctx argument.

You can use a type implementing this trait as your main window handler by wrapping it with a speedy2d::window::WindowHandler and passing the wrapper to speedy2d::Window::run_loop.

Provided Methods§

source

fn on_start( &mut self, helper: &mut WindowHelper<UserEventType>, info: WindowStartupInfo, egui_ctx: &Context )

Invoked once when the window first starts.

source

fn on_user_event( &mut self, helper: &mut WindowHelper<UserEventType>, user_event: UserEventType, egui_ctx: &Context )

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.

source

fn on_resize( &mut self, helper: &mut WindowHelper<UserEventType>, size_pixels: UVec2, egui_ctx: &Context )

Invoked when the window is resized.

source

fn on_mouse_grab_status_changed( &mut self, helper: &mut WindowHelper<UserEventType>, mouse_grabbed: bool, egui_ctx: &Context )

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.

source

fn on_fullscreen_status_changed( &mut self, helper: &mut WindowHelper<UserEventType>, fullscreen: bool, egui_ctx: &Context )

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

source

fn on_scale_factor_changed( &mut self, helper: &mut WindowHelper<UserEventType>, scale_factor: f64, egui_ctx: &Context )

Invoked when the window scale factor changes.

source

fn on_draw( &mut self, helper: &mut WindowHelper<UserEventType>, graphics: &mut Graphics2D, egui_ctx: &Context )

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.

source

fn on_mouse_move( &mut self, helper: &mut WindowHelper<UserEventType>, position: Vec2, egui_ctx: &Context )

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.

source

fn on_mouse_button_down( &mut self, helper: &mut WindowHelper<UserEventType>, button: MouseButton, egui_ctx: &Context )

Invoked when a mouse button is pressed.

source

fn on_mouse_button_up( &mut self, helper: &mut WindowHelper<UserEventType>, button: MouseButton, egui_ctx: &Context )

Invoked when a mouse button is released.

source

fn on_mouse_wheel_scroll( &mut self, helper: &mut WindowHelper<UserEventType>, distance: MouseScrollDistance, egui_ctx: &Context )

Invoked when the mouse wheel moves.

source

fn on_key_down( &mut self, helper: &mut WindowHelper<UserEventType>, virtual_key_code: Option<VirtualKeyCode>, scancode: KeyScancode, egui_ctx: &Context )

Invoked when a keyboard key is pressed.

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

source

fn on_key_up( &mut self, helper: &mut WindowHelper<UserEventType>, virtual_key_code: Option<VirtualKeyCode>, scancode: KeyScancode, egui_ctx: &Context )

Invoked when a keyboard key is released.

source

fn on_keyboard_char( &mut self, helper: &mut WindowHelper<UserEventType>, unicode_codepoint: char, egui_ctx: &Context )

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.

source

fn on_keyboard_modifiers_changed( &mut self, helper: &mut WindowHelper<UserEventType>, state: ModifiersState, egui_ctx: &Context )

Invoked when the state of the modifier keys has changed.

Implementors§