macOS: ⌘[ and ⌘] for back and forward, and a Go menu

What Finder and Safari use; alt-arrows from #12 still work. Only on the
explore screen, where the history buttons are.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tobi Lütke
2026-09-25 14:16:43 +00:00
co-authored by Claude Opus 5.5
parent 1220150762
commit 41331f363f
3 changed files with 28 additions and 4 deletions
+2 -2
View File
@@ -158,8 +158,8 @@ continuous motion, with the directory's contents growing into place. Scroll the
other way to come back out. Enter goes into the selected directory at any
depth, and Backspace or Escape goes up one level. `<` and `>`, beside the
Size / Files / Age switch, go back and forward through the directories visited,
as do `alt ←` `alt →` and the mouse's side buttons. `+` and `-` magnify without
going in; `0` resets.
as do `alt ←` `alt →` (also `⌘[` `⌘]` on macOS) and the mouse's side
buttons. `+` and `-` magnify without going in; `0` resets.
### Removing
+13 -2
View File
@@ -35,6 +35,10 @@ mod menu_actions {
OpenFolder,
/// Reveal the tile a key acts on in Finder.
ShowInFinder,
/// Back through the directories visited.
GoBack,
/// Forward again, after going back.
GoForward,
]
);
}
@@ -62,8 +66,8 @@ pub fn install(cx: &mut App) {
let _ = window.update(cx, |_, window, _| window.remove_window());
}
});
// `Rescan`, `OpenFolder` and `ShowInFinder` are handled by the window,
// which owns the scan and the selection; see `views::root`.
// `Rescan`, `OpenFolder`, `ShowInFinder` and the history are handled by
// the window, which owns the scan and the selection; see `views::root`.
cx.bind_keys([
KeyBinding::new("cmd-q", Quit, None),
KeyBinding::new("cmd-h", Hide, None),
@@ -74,6 +78,9 @@ pub fn install(cx: &mut App) {
// ⌘R is taken by Rescan, as in a browser; Xcode uses ⌘⇧R-like
// chords for its reveals, and `o` does the same without a modifier.
KeyBinding::new("cmd-shift-r", ShowInFinder, None),
// Finder's and Safari's back and forward; alt-arrows work too.
KeyBinding::new("cmd-[", GoBack, None),
KeyBinding::new("cmd-]", GoForward, None),
]);
cx.set_menus([
Menu::new("disktree").items([
@@ -93,5 +100,9 @@ pub fn install(cx: &mut App) {
MenuItem::separator(),
MenuItem::action("Close Window", CloseWindow),
]),
Menu::new("Go").items([
MenuItem::action("Back", GoBack),
MenuItem::action("Forward", GoForward),
]),
]);
}
+13
View File
@@ -75,6 +75,19 @@ pub fn root(
this.reveal_target(cx);
},
))
// Only where the history buttons are: the review screen has none.
.on_action(cx.listener(|this, _: &crate::app_menu::GoBack, _, cx| {
if this.screen == Screen::Explore {
this.go_back(cx);
}
}))
.on_action(cx.listener(
|this, _: &crate::app_menu::GoForward, _, cx| {
if this.screen == Screen::Explore {
this.go_forward(cx);
}
},
))
.on_key_down(cx.listener(|this, event: &KeyDownEvent, window, cx| {
if this.zoom_interface(event, window) {
cx.notify();