pub trait WinHandler {
Show 13 methods fn connect(&self, handle: &WindowHandle); fn paint(&self, ctx: &mut PaintCtx<'_>) -> bool; fn as_any(&self) -> &dyn Any; fn size(&self, width: u32, height: u32) { ... } fn rebuild_resources(&self) { ... } fn command(&self, id: u32) { ... } fn char(&self, ch: u32, mods: u32) { ... } fn keydown(&self, vkey_code: i32, mods: u32) -> bool { ... } fn mouse_wheel(&self, delta: i32, mods: u32) { ... } fn mouse_hwheel(&self, delta: i32, mods: u32) { ... } fn mouse_move(&self, x: i32, y: i32, mods: u32) { ... } fn mouse(&self, event: &MouseEvent) { ... } fn destroy(&self) { ... }
}
Expand description

App behavior, supplied by the app.

Many of the “window procedure” messages map to calls to this trait. The methods are non-mut because the window procedure can be called recursively; implementers are expected to use RefCell or the like, but should be careful to keep the lifetime of the borrow short.

Required Methods

Provide the handler with a handle to the window so that it can invalidate or make other requests.

Request the handler to paint the window contents. Return value indicates whether window is animating, i.e. whether another paint should be scheduled for the next animation frame.

Get a reference to the handler state. Used mostly by idle handlers.

Provided Methods

Called when the size of the window is changed. Note that size is in physical pixels.

Called when the resources need to be rebuilt.

Called when a menu item is selected.

Called on keyboard input of a single character. This corresponds to the WM_CHAR message. Handling of text input will continue to evolve, we need to handle input methods and more.

The modifiers are a combination of M_ALT, M_CTRL, M_SHIFT.

Called on a key down event. This corresponds to the WM_KEYDOWN message. The key code is as WM_KEYDOWN. We’ll want to add stuff like the modifier state.

The modifiers are a combination of M_ALT, M_CTRL, M_SHIFT.

Return true if the event is handled.

Called on a mouse wheel event. This corresponds to a WM_MOUSEWHEEL message.

The modifiers are the same as WM_MOUSEWHEEL.

Called on a mouse horizontal wheel event. This corresponds to a WM_MOUSEHWHEEL message.

The modifiers are the same as WM_MOUSEHWHEEL.

Called when the mouse moves. Note that the x, y coordinates are in absolute pixels.

TODO: should we reuse the MouseEvent struct for this method as well?

Called on mouse button up or down. Note that the x, y coordinates are in absolute pixels.

Called when the window is being destroyed. Note that this happens earlier in the sequence than drop (at WM_DESTROY, while the latter is WM_NCDESTROY).

Implementors