Skip to content

Commit

Permalink
Ensure overriding system-reserved shortcuts is not the default option.
Browse files Browse the repository at this point in the history
  • Loading branch information
tofumatt committed Oct 26, 2023
1 parent a73af47 commit b4cecb7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
"keyboard_shortcut_used_by_menu_item" = "This keyboard shortcut cannot be used as it’s already used by the “%@” menu item.";
"keyboard_shortcut_used_by_system" = "This keyboard shortcut cannot be used as it’s already a system-wide keyboard shortcut.";
"keyboard_shortcuts_can_be_changed" = "Most system-wide keyboard shortcuts can be changed in “System Settings › Keyboard › Keyboard Shortcuts”.";
"force_use_shortcut" = "Use Anyway";
"force_use_shortcut" = "Use Anyway";
"ok" = "OK";
9 changes: 4 additions & 5 deletions Sources/KeyboardShortcuts/RecorderCocoa.swift
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,15 @@ extension KeyboardShortcuts {
// TODO: Add button to offer to open the relevant system settings pane for the user.
message: "keyboard_shortcuts_can_be_changed".localized,
buttonTitles: [
"force_use_shortcut".localized,
"Cancel"
"ok".localized,
"force_use_shortcut".localized
]
)

self.focus()

// first button returned from alert means user wants to continue setting this
// shortcut despite it being used by system.
guard modalResponse == .alertFirstButtonReturn else {
// If the user has selected "Use Anyway" in the dialog (the second option), we'll continue setting the keyboard shorcut even though it's reserved by the system.
guard modalResponse == .alertSecondButtonReturn else {
return nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/KeyboardShortcuts/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ extension NSAlert {
self.messageText = title
self.alertStyle = style
self.icon = icon

for buttonTitle in buttonTitles {
self.addButton(withTitle: buttonTitle)
}
Expand Down

0 comments on commit b4cecb7

Please sign in to comment.