implemented applicationShouldTerminateAfterLastWindowClosed
This commit is contained in:
parent
5cd59b5636
commit
6b53b30565
|
@ -49,6 +49,9 @@ impl AppDelegate for CalculatorApp {
|
|||
self.window.set_content_view(&self.content);
|
||||
self.window.show();
|
||||
}
|
||||
fn should_terminate_after_last_window_closed(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl Dispatcher for CalculatorApp {
|
||||
|
|
|
@ -226,6 +226,14 @@ extern fn should_open_untitled_file<T: AppDelegate>(this: &Object, _: Sel, _: id
|
|||
}
|
||||
}
|
||||
|
||||
/// Fired when the application receives an `applicationShouldTerminateAfterLastWindowClosed:` message.
|
||||
extern fn should_terminate_after_last_window_closed<T: AppDelegate>(this: &Object, _: Sel, _: id) -> BOOL {
|
||||
match app::<T>(this).should_terminate_after_last_window_closed() {
|
||||
true => YES,
|
||||
false => NO
|
||||
}
|
||||
}
|
||||
|
||||
/// Fired when the application receives an `applicationOpenUntitledFile:` message.
|
||||
extern fn open_untitled_file<T: AppDelegate>(this: &Object, _: Sel, _: id) -> BOOL {
|
||||
match app::<T>(this).open_untitled_file() {
|
||||
|
@ -308,6 +316,7 @@ pub(crate) fn register_app_delegate_class<T: AppDelegate + AppDelegate>() -> *co
|
|||
// Terminating Applications
|
||||
decl.add_method(sel!(applicationShouldTerminate:), should_terminate::<T> as extern fn(&Object, _, _) -> NSUInteger);
|
||||
decl.add_method(sel!(applicationWillTerminate:), will_terminate::<T> as extern fn(&Object, _, _));
|
||||
decl.add_method(sel!(applicationShouldTerminateAfterLastWindowClosed:), should_terminate_after_last_window_closed::<T> as extern fn(&Object, _, _) -> BOOL);
|
||||
|
||||
// Hiding Applications
|
||||
decl.add_method(sel!(applicationWillHide:), will_hide::<T> as extern fn(&Object, _, _));
|
||||
|
|
|
@ -98,6 +98,10 @@ pub trait AppDelegate {
|
|||
/// back.
|
||||
fn should_terminate(&self) -> TerminateResponse { TerminateResponse::Now }
|
||||
|
||||
/// Called after closing the last open window. Return `true` here if you want
|
||||
/// the application to terminate.
|
||||
fn should_terminate_after_last_window_closed(&self) -> bool { false }
|
||||
|
||||
/// Sent by the application to the delegate prior to default behavior to reopen AppleEvents.
|
||||
///
|
||||
/// `has_visible_windows` indicates whether the Application object found any visible windows in your application.
|
||||
|
|
Loading…
Reference in a new issue