pub struct MessageLoop { /* private fields */ }Expand description
Abstract representation of a message loop.
Not directly constructible. Use MessageLoop::run to create a message
loop. The message loop struct is used to control message loop behavior
by passing it as an argument to the filter closure of MessageLoop::run.
Implementations§
Source§impl MessageLoop
impl MessageLoop
Sourcepub fn run(filter: impl Fn(&MessageLoop, &MSG) -> FilterResult)
pub fn run(filter: impl Fn(&MessageLoop, &MSG) -> FilterResult)
Runs the message loop with a filter closure to inspect and drop messages before they are dispatched to their respective window procedures.
Use the FilterResult return value to control how the message is handled.
The first argument to the filter closure is the MessageLoop struct itself,
which can be used to quit the message loop.
Like block_on(), this function runs any tasks spawned from the same thread
using spawn_local(). All tasks are suspended when this function returns.
Installs a WH_MSGFILTER hook to allow inspection of messages while modal
windows are open.
§Panics and Reentrancy
Panics if called from within another MessageLoop::run() filter closure.
A call to block_on() from within the filter closure creates a nested message
loop, which causes the filter closure to be re-entered when a modal window is open.
Sourcepub fn quit_when_idle(&self)
pub fn quit_when_idle(&self)
Quits the message loop when there are no more messages to process.