Skip to content

A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.

Open/Save dialog: Tab from the list goes to the name box

Marcos Gramelich93b71a708e0c
diff --git a/crates/rf-app/src/actions.rs b/crates/rf-app/src/actions.rs
index 620e9302..fed95926 100644
--- a/crates/rf-app/src/actions.rs
+++ b/crates/rf-app/src/actions.rs
@@ -151,7 +151,8 @@ pub fn bind(cx: &mut App) {
let f = Some(FOLDER_CTX);
cx.bind_keys([KeyBinding::new("tab", LeaveTree, Some(TREE_CTX))]);
// Tab and Shift+Tab walk the window's panes: the address bar, the folder tree, the file list (issue 38: "TAB does not work
- // anywhere"). In the list's own context, nearer than the root's Tab; the tree's Shift+Tab goes up to the window's handler.
+ // anywhere"), and in the Open / Save dialog the name box after the list, as in Windows' own dialog. In the list's own
+ // context, nearer than the root's Tab; the tree's Shift+Tab goes up to the window's handler.
cx.bind_keys([
KeyBinding::new("tab", FocusNextPane, Some(FOLDER_CTX)),
KeyBinding::new("shift-tab", FocusPrevPane, Some(FOLDER_CTX)),
diff --git a/crates/rf-app/src/workspace.rs b/crates/rf-app/src/workspace.rs
index 08ba35f0..124fe124 100644
--- a/crates/rf-app/src/workspace.rs
+++ b/crates/rf-app/src/workspace.rs
@@ -1313,6 +1313,7 @@ impl Workspace {
/// Tab (`forward`) and Shift+Tab: the keyboard goes round the window's panes, the address bar, the folder tree (when it is on
/// screen) and the file list, as Explorer's Tab does (issue 38: "TAB does not work anywhere"). A rename in the list keeps it.
+ /// In the Open / Save dialog the name box is one of the stops, right after the list, as in Windows' own dialog.
fn cycle_focus(&mut self, forward: bool, window: &mut Window, cx: &mut Context<Self>) {
if self.active_tab().read(cx).renaming.is_some() {
// (in the rename box Tab goes on to the next item's name, issue 395)
@@ -1320,15 +1321,30 @@ impl Workspace {
return;
}
let tree = self.tree_focus(cx);
+ let picker = self.picker();
+ let in_name = picker.as_ref().is_some_and(|s| s.name.read(cx).focus_handle(cx).is_focused(window));
let here = if self.editing_address {
Pane::Address
+ } else if in_name {
+ Pane::Name
} else if tree.as_ref().is_some_and(|f| f.is_focused(window)) {
Pane::Tree
} else {
Pane::List
};
- match next_pane(here, forward, tree.is_some()) {
+ match next_pane(here, forward, tree.is_some(), picker.is_some()) {
Pane::Address => self.begin_address_edit(window, cx),
+ // (the dialog's name box: a click in the list and Tab there brings the keyboard to the name, as Windows' dialog does)
+ Pane::Name => {
+ if self.editing_address {
+ self.editing_address = false;
+ self.clear_suggestions();
+ }
+ if let Some(s) = picker {
+ s.name.update(cx, |st, cx| st.focus(window, cx));
+ }
+ cx.notify();
+ }
to => {
if self.editing_address {
self.editing_address = false;
@@ -6694,6 +6710,15 @@ impl Render for Workspace {
if nav && !s.name.read(cx).focus_handle(cx).is_focused(window) {
s.touched.set(true);
}
+ // Tab in the name box: the list's own Tab binding belongs to the list's key context, which the box
+ // is not in, so the key reaches this listener; the box goes on round the dialog as the list does
+ // (issue 389's dialog: the list, then the name box).
+ if k.key == "tab" && !k.modifiers.control && !k.modifiers.alt && !k.modifiers.platform {
+ if s.name.read(cx).focus_handle(cx).is_focused(window) {
+ cx.stop_propagation();
+ this.cycle_focus(!k.modifiers.shift, window, cx);
+ }
+ }
// (Escape in the name box; in the list it is the list's, which tells us: FolderEvent::Escape)
if k.key == "escape" && !k.modifiers.modified() && s.name.read(cx).focus_handle(cx).is_focused(window) {
cx.stop_propagation();
@@ -6897,11 +6922,17 @@ enum Pane {
Address,
Tree,
List,
+ /// The Open / Save dialog's name box, only in a window that is one.
+ Name,
}
-/// The pane after `here` (`forward`) or before it, round; the tree is skipped when it is not on screen.
-fn next_pane(here: Pane, forward: bool, tree: bool) -> Pane {
- let order: Vec<Pane> = [Pane::Address, Pane::Tree, Pane::List].into_iter().filter(|p| *p != Pane::Tree || tree).collect();
+/// The pane after `here` (`forward`) or before it, round; the tree is skipped when it is not on screen, and the name box when the
+/// window is not the Open / Save dialog.
+fn next_pane(here: Pane, forward: bool, tree: bool, picker: bool) -> Pane {
+ let order: Vec<Pane> = [Pane::Address, Pane::Tree, Pane::List, Pane::Name]
+ .into_iter()
+ .filter(|p| (*p != Pane::Tree || tree) && (*p != Pane::Name || picker))
+ .collect();
let i = order.iter().position(|p| *p == here).unwrap_or(order.len() - 1);
let n = order.len();
order[if forward { (i + 1) % n } else { (i + n - 1) % n }]
@@ -6913,13 +6944,24 @@ mod pane_tests {
#[test]
fn tab_goes_round_the_address_bar_the_tree_and_the_list() {
- assert_eq!(next_pane(Pane::List, true, true), Pane::Address);
- assert_eq!(next_pane(Pane::Address, true, true), Pane::Tree);
- assert_eq!(next_pane(Pane::Tree, true, true), Pane::List);
- assert_eq!(next_pane(Pane::List, false, true), Pane::Tree);
- assert_eq!(next_pane(Pane::Address, false, true), Pane::List);
- assert_eq!(next_pane(Pane::Address, true, false), Pane::List, "no tree on screen: it is skipped");
- assert_eq!(next_pane(Pane::List, false, false), Pane::Address);
+ assert_eq!(next_pane(Pane::List, true, true, false), Pane::Address);
+ assert_eq!(next_pane(Pane::Address, true, true, false), Pane::Tree);
+ assert_eq!(next_pane(Pane::Tree, true, true, false), Pane::List);
+ assert_eq!(next_pane(Pane::List, false, true, false), Pane::Tree);
+ assert_eq!(next_pane(Pane::Address, false, true, false), Pane::List);
+ assert_eq!(next_pane(Pane::Address, true, false, false), Pane::List, "no tree on screen: it is skipped");
+ assert_eq!(next_pane(Pane::List, false, false, false), Pane::Address);
+ }
+
+ /// The Open / Save dialog: from the list Tab goes to the name box, as in Windows' own dialog, and Shift+Tab from the box back to
+ /// the list.
+ #[test]
+ fn in_the_dialog_tab_from_the_list_reaches_the_name_box() {
+ assert_eq!(next_pane(Pane::List, true, true, true), Pane::Name);
+ assert_eq!(next_pane(Pane::List, true, false, true), Pane::Name);
+ assert_eq!(next_pane(Pane::Name, false, true, true), Pane::List);
+ assert_eq!(next_pane(Pane::Name, true, false, true), Pane::Address, "the box is the last stop: it goes round");
+ assert_eq!(next_pane(Pane::Address, false, true, true), Pane::Name);
}
}