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

@ -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 || {