Implement default macOS menu items

- `Zed -> Hide`, bound to `cmd-h`
- `Zed -> Hide Others`, bound to `alt-cmd-h`
- `Zed -> Show All`
- `Window -> Minimize`, bound to `cmd-m`
- `Window -> Zoom`
This commit is contained in:
Antonio Scandurra 2022-08-03 15:13:30 +02:00
parent dc9df64078
commit 7cbf76ce80
8 changed files with 124 additions and 1 deletions

View file

@ -456,6 +456,27 @@ impl platform::Platform for MacPlatform {
self.fonts.clone()
}
fn hide(&self) {
unsafe {
let app = NSApplication::sharedApplication(nil);
let _: () = msg_send![app, hide: nil];
}
}
fn hide_other_apps(&self) {
unsafe {
let app = NSApplication::sharedApplication(nil);
let _: () = msg_send![app, hideOtherApplications: nil];
}
}
fn unhide_other_apps(&self) {
unsafe {
let app = NSApplication::sharedApplication(nil);
let _: () = msg_send![app, unhideAllApplications: nil];
}
}
fn quit(&self) {
// Quitting the app causes us to close windows, which invokes `Window::on_close` callbacks
// synchronously before this method terminates. If we call `Platform::quit` while holding a