Bind cmd-? to assistant::toggle_focus

Bypass system help menu shortcut at the app delegate level to achieve this.

Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
This commit is contained in:
Nathan Sobo 2023-06-28 11:43:24 +02:00
parent 7efcd60608
commit 8f8a99d788
4 changed files with 24 additions and 3 deletions

View File

@ -408,6 +408,7 @@
"cmd-shift-p": "command_palette::Toggle",
"cmd-shift-m": "diagnostics::Deploy",
"cmd-shift-e": "project_panel::ToggleFocus",
"cmd-?": "assistant::ToggleFocus",
"cmd-alt-s": "workspace::SaveAll",
"cmd-k m": "language_selector::Toggle"
}

View File

@ -152,6 +152,29 @@ impl App {
asset_source,
))));
foreground_platform.on_event(Box::new({
let cx = app.0.clone();
move |event| {
if let Event::KeyDown(KeyDownEvent { keystroke, .. }) = &event {
// Allow system menu "cmd-?" shortcut to be overridden
if keystroke.cmd
&& !keystroke.shift
&& !keystroke.alt
&& !keystroke.function
&& keystroke.key == "?"
{
if cx
.borrow_mut()
.update_active_window(|cx| cx.dispatch_keystroke(keystroke))
.unwrap_or(false)
{
return true;
}
}
}
false
}
}));
foreground_platform.on_quit(Box::new({
let cx = app.0.clone();
move || {

View File

@ -939,7 +939,6 @@ extern "C" fn send_event(this: &mut Object, _sel: Sel, native_event: id) {
}
}
}
msg_send![super(this, class!(NSApplication)), sendEvent: native_event]
}
}

View File

@ -72,8 +72,6 @@ fn main() {
let installation_id = app.background().block(installation_id()).ok();
init_panic_hook(&app, installation_id.clone());
app.background();
load_embedded_fonts(&app);
let fs = Arc::new(RealFs);