Fix panic on quit
This commit is contained in:
parent
107c3d7f67
commit
47b4d9942f
3 changed files with 21 additions and 6 deletions
|
@ -1517,6 +1517,13 @@ impl<'a> WindowContext<'a> {
|
|||
.set_input_handler(Box::new(input_handler));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn on_window_should_close(&mut self, f: impl Fn(&mut WindowContext) -> bool + 'static) {
|
||||
let mut this = self.to_async();
|
||||
self.window
|
||||
.platform_window
|
||||
.on_should_close(Box::new(move || this.update(|_, cx| f(cx)).unwrap_or(true)))
|
||||
}
|
||||
}
|
||||
|
||||
impl Context for WindowContext<'_> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue