From 55110902749b82abe253fe1f50abc23ac7005bf5 Mon Sep 17 00:00:00 2001
From: hacknus <33124824+hacknus@users.noreply.github.com>
Date: Sat, 23 Nov 2024 15:24:42 +0100
Subject: [PATCH] feat: use cmd key for keybindings on macos (#205)
* change all ctrl keys to command
---
README.md | 7 ++++---
src/config/keybindings.rs | 4 ++--
src/file_dialog.rs | 8 +++++---
src/lib.rs | 6 +++---
4 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/README.md b/README.md
index b6476e8d..d94a59c4 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@ The latest changes included in the next release can be found in the [CHANGELOG.m
- Select a file or a directory
- Save a file (Prompt user for a destination path)
- Dialog to ask the user if the existing file should be overwritten
-- Select multiple files and folders at once (ctrl/shift + click)
+- Select multiple files and folders at once (ctrl/shift + click on linux/windows and cmd/shift + click on macOS)
- Open the dialog in a normal or modal window
- Create a new folder
- Keyboard navigation
@@ -127,12 +127,13 @@ The following table lists all available keybindings and their default values.
| back | Go back | `Mouse button 1`
`ALT` + `←`
`Backspace` |
| forward | Go forward | `Mouse button 2`
`ALT` + `→` |
| reload | Reload the file dialog data and the currently open directory | `F5` |
-| new_folder | Open the dialog to create a new folder | `CTRL` + `N` |
+| new_folder | Open the dialog to create a new folder | `CTRL` + `N` on linux/windows or `CMD` + `N` on macOS |
| edit_path | Text edit the current path | `/` |
| home_edit_path | Open the home directory and start text editing the path | `~` |
| selection_up | Move the selection one item up | `↑` |
| selection_down | Move the selection one item down | `↓` |
-| select_all | Select every item in the directory when using the file dialog to select multiple files and folders | `CTRL` + `A` |
+| select_all | Select every item in the directory when using the file dialog to select multiple files and folders |
+`CTRL` + `A` on linux/windows or `CMD` + `A` on macOS |
## Customization
Many things can be customized so that the dialog can be used in different situations. \
diff --git a/src/config/keybindings.rs b/src/config/keybindings.rs
index ece7ee45..9c2a8aa8 100644
--- a/src/config/keybindings.rs
+++ b/src/config/keybindings.rs
@@ -156,7 +156,7 @@ impl Default for FileDialogKeyBindings {
KeyBinding::keyboard_shortcut(Modifiers::ALT, Key::ArrowRight),
],
reload: vec![KeyBinding::key(egui::Key::F5)],
- new_folder: vec![KeyBinding::keyboard_shortcut(Modifiers::CTRL, Key::N)],
+ new_folder: vec![KeyBinding::keyboard_shortcut(Modifiers::COMMAND, Key::N)],
edit_path: vec![KeyBinding::key(Key::Slash)],
home_edit_path: vec![
KeyBinding::keyboard_shortcut(Modifiers::SHIFT, egui::Key::Backtick),
@@ -164,7 +164,7 @@ impl Default for FileDialogKeyBindings {
],
selection_up: vec![KeyBinding::key(Key::ArrowUp)],
selection_down: vec![KeyBinding::key(Key::ArrowDown)],
- select_all: vec![KeyBinding::keyboard_shortcut(Modifiers::CTRL, Key::A)],
+ select_all: vec![KeyBinding::keyboard_shortcut(Modifiers::COMMAND, Key::A)],
}
}
}
diff --git a/src/file_dialog.rs b/src/file_dialog.rs
index bf1a1d24..54cfa60a 100644
--- a/src/file_dialog.rs
+++ b/src/file_dialog.rs
@@ -2195,7 +2195,7 @@ impl FileDialog {
// The user wants to select the item as the primary selected item
if re.clicked()
- && !ui.input(|i| i.modifiers.ctrl)
+ && !ui.input(|i| i.modifiers.command)
&& !ui.input(|i| i.modifiers.shift_only())
{
self.select_item(item);
@@ -2208,7 +2208,9 @@ impl FileDialog {
// The user wants to select or unselect the item as part of a
// multi selection
- if self.mode == DialogMode::SelectMultiple && re.clicked() && ui.input(|i| i.modifiers.ctrl)
+ if self.mode == DialogMode::SelectMultiple
+ && re.clicked()
+ && ui.input(|i| i.modifiers.command)
{
if primary_selected {
// If the clicked item is the primary selected item,
@@ -2244,7 +2246,7 @@ impl FileDialog {
// The user double clicked on the directory entry.
// Either open the directory or submit the dialog.
- if re.double_clicked() && !ui.input(|i| i.modifiers.ctrl) {
+ if re.double_clicked() && !ui.input(|i| i.modifiers.command) {
if item.is_dir() {
self.load_directory(&item.to_path_buf());
return true;
diff --git a/src/lib.rs b/src/lib.rs
index 2602f7e2..600d9bf6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -11,7 +11,7 @@
//! - Select a file or a directory
//! - Save a file (Prompt user for a destination path)
//! - Dialog to ask the user if the existing file should be overwritten
-//! - Select multiple files and folders at once (ctrl/shift + click)
+//! - Select multiple files and folders at once (ctrl/shift + click on linux/windows or cmd/shift + click on macOS)
//! - Open the dialog in a normal or modal window
//! - Create a new folder
//! - Keyboard navigation
@@ -78,12 +78,12 @@
//! | `back` | Go back | `Mouse button 1`
`ALT` + `←`
`Backspace` |
//! | `forward` | Go forward | `Mouse button 2`
`ALT` + `→` |
//! | `reload` | Reload the file dialog data and the currently open directory | `F5` |
-//! | `new_folder` | Open the dialog to create a new folder | `CTRL` + `N` |
+//! | `new_folder` | Open the dialog to create a new folder | `CTRL` + `N` on linux/windows or `CMD` + `N` on macOS |
//! | `edit_path` | Text edit the current path | `/` |
//! | `home_edit_path` | Open the home directory and start text editing the path | `~` |
//! | `selection_up` | Move the selection one item up | `↑` |
//! | `selection_down` | Move the selection one item down | `↓` |
-//! | `select_all` | Select every item in the directory when using the file dialog to select multiple files and folders | `CTRL` + `A` |
+//! | `select_all` | Select every item in the directory when using the file dialog to select multiple files and folders | `CTRL` + `A` on linux/windows or `CMD` + `A` on macOS |
//!
//! ### Customization
//! Many things can be customized so that the dialog can be used in different situations. \