Skip to content

Commit 5d0a46f

Browse files
author
Kamil Daniel
committed
Show an alert when trying to assign a shortcut that’s already in use.
1 parent 2927f70 commit 5d0a46f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Sources/KeyboardShortcuts/KeyboardShortcuts.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,9 @@ public enum KeyboardShortcuts {
381381

382382
private static func handleOnKeyDown(_ shortcut: Shortcut) {
383383
guard !isPaused else {
384+
NSAlert.showModal(
385+
for: nil,
386+
title: "keyboard_shortcut_used_by_other_action".localized)
384387
return
385388
}
386389

@@ -407,6 +410,9 @@ public enum KeyboardShortcuts {
407410

408411
private static func handleOnKeyUp(_ shortcut: Shortcut) {
409412
guard !isPaused else {
413+
NSAlert.showModal(
414+
for: nil,
415+
title: "keyboard_shortcut_used_by_other_action".localized)
410416
return
411417
}
412418

Sources/KeyboardShortcuts/Localization/en.lproj/Localizable.strings

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"record_shortcut" = "Record Shortcut";
22
"press_shortcut" = "Press Shortcut";
3+
"keyboard_shortcut_used_by_other_action" = "This keyboard shortcut is already assigned to another action."
34
"keyboard_shortcut_used_by_menu_item" = "This keyboard shortcut cannot be used as it’s already used by the “%@” menu item.";
4-
"keyboard_shortcut_used_by_system" = "This keyboard shortcut cannot be used as it’s already a system-wide keyboard shortcut.";
5+
"keyboard_shortcut_used_by_system" = "This keyboard shortcut cannot be used as it’s already a system-wide keyboard shortcut2.";
56
"keyboard_shortcuts_can_be_changed" = "Most system-wide keyboard shortcuts can be changed in “System Settings › Keyboard › Keyboard Shortcuts”.";
67
"keyboard_shortcut_disallowed" = "Option modifier must be combined with Command or Control.";
78
"force_use_shortcut" = "Use Anyway";

0 commit comments

Comments
 (0)