Trait druid_win_shell::window::WinHandler
source · 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
sourcefn connect(&self, handle: &WindowHandle)
fn connect(&self, handle: &WindowHandle)
Provide the handler with a handle to the window so that it can invalidate or make other requests.
Provided Methods
sourcefn size(&self, width: u32, height: u32)
fn size(&self, width: u32, height: u32)
Called when the size of the window is changed. Note that size is in physical pixels.
sourcefn rebuild_resources(&self)
fn rebuild_resources(&self)
Called when the resources need to be rebuilt.
sourcefn char(&self, ch: u32, mods: u32)
fn char(&self, ch: u32, mods: u32)
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
.
sourcefn keydown(&self, vkey_code: i32, mods: u32) -> bool
fn keydown(&self, vkey_code: i32, mods: u32) -> bool
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.
sourcefn mouse_wheel(&self, delta: i32, mods: u32)
fn mouse_wheel(&self, delta: i32, mods: u32)
Called on a mouse wheel event. This corresponds to a WM_MOUSEWHEEL message.
The modifiers are the same as WM_MOUSEWHEEL.
sourcefn mouse_hwheel(&self, delta: i32, mods: u32)
fn mouse_hwheel(&self, delta: i32, mods: u32)
Called on a mouse horizontal wheel event. This corresponds to a WM_MOUSEHWHEEL message.
The modifiers are the same as WM_MOUSEHWHEEL.
sourcefn mouse_move(&self, x: i32, y: i32, mods: u32)
fn mouse_move(&self, x: i32, y: i32, mods: u32)
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?
sourcefn mouse(&self, event: &MouseEvent)
fn mouse(&self, event: &MouseEvent)
Called on mouse button up or down. Note that the x, y coordinates are in absolute pixels.