Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

9 make private static func unregisterall public #186

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added Sources/.DS_Store
Binary file not shown.
33 changes: 25 additions & 8 deletions Sources/KeyboardShortcuts/KeyboardShortcuts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,6 @@
unregisterIfNeeded(shortcut)
}

private static func unregisterAll() {
CarbonKeyboardShortcuts.unregisterAll()
registeredShortcuts.removeAll()

// TODO: Should remove user defaults too.
}

static func initialize() {
guard !isInitialized else {
return
Expand Down Expand Up @@ -241,7 +234,7 @@
setShortcut(name.defaultShortcut, for: name)
}
}

Check warning on line 237 in Sources/KeyboardShortcuts/KeyboardShortcuts.swift

View workflow job for this annotation

GitHub Actions / lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)

Check warning on line 237 in Sources/KeyboardShortcuts/KeyboardShortcuts.swift

View workflow job for this annotation

GitHub Actions / lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
/**
Reset the keyboard shortcut for one or more names.

Expand Down Expand Up @@ -270,6 +263,30 @@
reset(names)
}

/**
Reset all keyboard shortcuts and remove their stored values from `UserDefaults`.

This method resets all keyboard shortcuts registered via `KeyboardShortcuts` and removes any associated data stored in `UserDefaults`.

Use this method to completely reset the state of all keyboard shortcuts in your app, including removing any saved user-defined shortcuts and default shortcuts.

- Note: This action cannot be undone. All shortcuts will be removed, including any default shortcuts defined in `Name`. If you want to reset shortcuts back to their default values, consider using `.reset(_:)` instead.

- Important: This method affects all shortcuts registered with `KeyboardShortcuts` and should be used with caution.
*/
public static func resetAll() {
// remove shortcuts
CarbonKeyboardShortcuts.unregisterAll()
registeredShortcuts.removeAll()

Check warning on line 281 in Sources/KeyboardShortcuts/KeyboardShortcuts.swift

View workflow job for this annotation

GitHub Actions / lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)

Check warning on line 281 in Sources/KeyboardShortcuts/KeyboardShortcuts.swift

View workflow job for this annotation

GitHub Actions / lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
// remove userdefaults
let userDefaults = UserDefaults.standard

for key in userDefaults.dictionaryRepresentation().keys where key.hasPrefix("KeyboardShortcuts_") {
userDefaults.removeObject(forKey: key)
}
}

Check warning on line 289 in Sources/KeyboardShortcuts/KeyboardShortcuts.swift

View workflow job for this annotation

GitHub Actions / lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)

Check warning on line 289 in Sources/KeyboardShortcuts/KeyboardShortcuts.swift

View workflow job for this annotation

GitHub Actions / lint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
/**
Set the keyboard shortcut for a name.

Expand Down
Loading