From 726476a42c18b86630d22f2a760499737dc05acd Mon Sep 17 00:00:00 2001 From: Lost Paul <70213368+LostPaul@users.noreply.github.com> Date: Tue, 22 Jul 2025 10:27:36 +0200 Subject: [PATCH] Fix #268 --- src/events/handleClick.ts | 3 ++- src/main.ts | 8 +++++--- src/settings/GeneralSettings.ts | 6 ++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/events/handleClick.ts b/src/events/handleClick.ts index 4bb35bd..4b3035a 100644 --- a/src/events/handleClick.ts +++ b/src/events/handleClick.ts @@ -36,7 +36,8 @@ export async function handleViewHeaderClick(event: MouseEvent, plugin: FolderNot }); return; } else if (event.altKey || Keymap.isModEvent(event) === 'tab') { - if ((plugin.settings.altKey && event.altKey) || (plugin.settings.ctrlKey && Keymap.isModEvent(event) === 'tab')) { + const usedCtrl = Platform.isMacOS ? event.metaKey : event.ctrlKey; + if ((plugin.settings.altKey && event.altKey) || (usedCtrl && Keymap.isModEvent(event) === 'tab')) { await createFolderNote(plugin, folderPath, true, undefined, true); addCSSClassToFileExplorerEl(folderPath, 'has-folder-note', false, plugin); removeCSSClassFromFileExplorerEL(folderPath, 'has-not-folder-note', false, plugin); diff --git a/src/main.ts b/src/main.ts index 8255ddc..e2935cd 100644 --- a/src/main.ts +++ b/src/main.ts @@ -278,9 +278,11 @@ export default class FolderNotesPlugin extends Plugin { const excludedFolder = getExcludedFolder(this, folderPath, true); if (excludedFolder?.disableFolderNote) return; + const usedCtrl = Platform.isMacOS ? evt.metaKey : evt.ctrlKey; + const folderNote = getFolderNote(this, folderPath); if (!folderNote && (evt.altKey || Keymap.isModEvent(evt) === 'tab')) { - if ((this.settings.altKey && evt.altKey) || (this.settings.ctrlKey && Keymap.isModEvent(evt) === 'tab')) { + if ((this.settings.altKey && evt.altKey) || (usedCtrl && this.settings.ctrlKey)) { createFolderNote(this, folderPath, true, undefined, true); addCSSClassToFileExplorerEl(folderPath, 'has-folder-note', false, this); removeCSSClassFromFileExplorerEL(folderPath, 'has-not-folder-note', false, this); @@ -289,10 +291,10 @@ export default class FolderNotesPlugin extends Plugin { } if (!(folderNote instanceof TFile)) return; - if (this.settings.openWithCtrl && !evt.ctrlKey) return; + if (this.settings.openWithCtrl && !usedCtrl) return; if (this.settings.openWithAlt && !evt.altKey) return; - if (!this.settings.enableCollapsing || evt.ctrlKey) { + if (!this.settings.enableCollapsing || usedCtrl) { evt.preventDefault(); evt.stopImmediatePropagation(); } diff --git a/src/settings/GeneralSettings.ts b/src/settings/GeneralSettings.ts index a588e84..495361e 100644 --- a/src/settings/GeneralSettings.ts +++ b/src/settings/GeneralSettings.ts @@ -254,10 +254,11 @@ export async function renderGeneral(settingsTab: SettingsTab) { .addDropdown((dropdown) => { if (!Platform.isMacOS) { dropdown.addOption('ctrl', 'Ctrl + Click'); + dropdown.addOption('alt', 'Alt + Click'); } else { dropdown.addOption('ctrl', 'Cmd + Click'); + dropdown.addOption('alt', 'Option + Click'); } - dropdown.addOption('alt', 'Alt + Click'); dropdown.setValue(settingsTab.plugin.settings.ctrlKey ? 'ctrl' : 'alt'); dropdown.onChange(async (value) => { settingsTab.plugin.settings.ctrlKey = value === 'ctrl'; @@ -274,10 +275,11 @@ export async function renderGeneral(settingsTab: SettingsTab) { dropdown.addOption('click', 'Mouse Click'); if (!Platform.isMacOS) { dropdown.addOption('ctrl', 'Ctrl + Click'); + dropdown.addOption('alt', 'Alt + Click'); } else { dropdown.addOption('ctrl', 'Cmd + Click'); + dropdown.addOption('alt', 'Option + Click'); } - dropdown.addOption('alt', 'Alt + Click'); if (settingsTab.plugin.settings.openByClick) { dropdown.setValue('click'); } else if (settingsTab.plugin.settings.openWithCtrl) {