Trait WindowMessageListener

Source
pub trait WindowMessageListener {
    // Provided methods
    fn handle_menu_command(&self, window: &WindowHandle, selected_item_id: u32) { ... }
    fn handle_window_minimized(&self, window: &WindowHandle) { ... }
    fn handle_window_close(&self, window: &WindowHandle) -> ListenerAnswer { ... }
    fn handle_window_destroy(&self, window: &WindowHandle) { ... }
    fn handle_notification_icon_select(&self, icon_id: u16, xy_coords: Point) { ... }
    fn handle_notification_icon_context_select(
        &self,
        icon_id: u16,
        xy_coords: Point,
    ) { ... }
    fn handle_custom_user_message(
        &self,
        window: &WindowHandle,
        message_id: u8,
        w_param: WPARAM,
        l_param: LPARAM,
    ) { ... }
}
Available on crate feature ui only.
Expand description

A user-defined implementation for various windows message handlers.

The trait already defines a default for all methods, making it easier to just implement specific ones.

§Design rationale

The way the Windows API is structured, it doesn’t seem to be possible to use closures here due to crate::ui::Window and crate::ui::WindowClass needing type parameters for the WindowMessageListener, making it hard to swap out the listener since every Fn has its own type in Rust.

Box with dynamic dispatch Fn is also not practical due to allowing only 'static lifetimes.

Provided Methods§

Source

fn handle_menu_command(&self, window: &WindowHandle, selected_item_id: u32)

An item from a window’s menu was selected by the user.

Source

fn handle_window_minimized(&self, window: &WindowHandle)

A ‘minimize window’ action was performed.

Source

fn handle_window_close(&self, window: &WindowHandle) -> ListenerAnswer

A ‘close window’ action was performed.

Source

fn handle_window_destroy(&self, window: &WindowHandle)

A window was destroyed and removed from the screen.

Source

fn handle_notification_icon_select(&self, icon_id: u16, xy_coords: Point)

A notification icon was selected (triggered).

Source

fn handle_notification_icon_context_select( &self, icon_id: u16, xy_coords: Point, )

A notification icon was context-selected (e.g. right-clicked).

Source

fn handle_custom_user_message( &self, window: &WindowHandle, message_id: u8, w_param: WPARAM, l_param: LPARAM, )

A custom user message was sent.

Implementors§