[][src]Trait pel::Events

pub trait Events {
    fn init(&mut self, ctx: &mut Context) { ... }
fn window_focus(&mut self, ctx: &mut Context, focus: bool) { ... }
fn window_resized(&mut self, ctx: &mut Context, size: (usize, usize)) { ... }
fn cursor_focus(&mut self, ctx: &mut Context, focus: bool) { ... }
fn text_input(&mut self, ctx: &mut Context, codepoint: char) { ... }
fn key_input(&mut self, ctx: &mut Context, input: KeyboardInput) { ... }
fn mouse_moved(&mut self, ctx: &mut Context, pos: (usize, usize)) { ... }
fn mouse_click(&mut self, ctx: &mut Context, click: MouseInput) { ... }
fn mouse_scroll(&mut self, ctx: &mut Context, delta: f32) { ... }
fn keyboard_modifiers(&mut self, ctx: &mut Context, modifiers: ModifierKeys) { ... }
fn update(&mut self, ctx: &mut Context) { ... }
fn draw(&mut self, ctx: &mut Context) { ... }
fn exit_requested(&mut self, ctx: &mut Context) -> bool { ... }
fn exit(&mut self) { ... } }

Pel event loop callbacks.

User should implement this trait for their type and provide it to Config::run.

Provided methods

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

Called once, immediately after Config::run is called.

This indicates that the pel event loop was just initialized.

fn window_focus(&mut self, ctx: &mut Context, focus: bool)

Called when pel window focus changes.

focus is current window focus state.

fn window_resized(&mut self, ctx: &mut Context, size: (usize, usize))

Called when window is resized.

size is in physical pixels.

fn cursor_focus(&mut self, ctx: &mut Context, focus: bool)

Called when cursor enters (focused) or leaves (unfocused) window client area.

focus is current cursor focus state.

fn text_input(&mut self, ctx: &mut Context, codepoint: char)

Called when key that has textual meaning is pressed.

fn key_input(&mut self, ctx: &mut Context, input: KeyboardInput)

Called when key is pressed.

scancode is physical location on the keyboard.

fn mouse_moved(&mut self, ctx: &mut Context, pos: (usize, usize))

Called when mouse cursor changes position.

pos is in physical pixels.

fn mouse_click(&mut self, ctx: &mut Context, click: MouseInput)

Called when mouse button state changes.

fn mouse_scroll(&mut self, ctx: &mut Context, delta: f32)

Called when mouse scrollwheel is moved.

delta is virtual lines. Positive values go up, or away from user, negative values - down or to user.

fn keyboard_modifiers(&mut self, ctx: &mut Context, modifiers: ModifierKeys)

Called when keyboard modifier keys state changes.

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

Called every frame before draw.

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

Called every frame after update.

fn exit_requested(&mut self, ctx: &mut Context) -> bool

Called when pel window receives close request.

Return value indicates if window should be closed.

fn exit(&mut self)

Called when pel event loop is being shut down.

This is guaranteed to be the last callback ever called.

Loading content...

Implementors

Loading content...