Skip to content

Commit

Permalink
pref: shortcut cmd + C conflict (#446)
Browse files Browse the repository at this point in the history
* pref: shortcut store logic

* fix: remove store keyCombo when user clear

---------

Co-authored-by: Tisfeng <tisfeng@gmail.com>
  • Loading branch information
AkaShark and tisfeng authored Mar 10, 2024
1 parent 1c9c88f commit 838b1d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Easydict/NewApp/Feature/Shortcut/Shortcut.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ extension Shortcut {
// binding shortcut
extension Shortcut {
func bindingShortcut(keyCombo: KeyCombo?, type: ShortcutType) {
HotKeyCenter.shared.unregisterHotKey(with: type.rawValue)
guard let keyCombo else {
HotKeyCenter.shared.unregisterHotKey(with: type.rawValue)
return
}
var hotKey: HotKey?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,17 @@ extension KeyHolderWrapper {
@Binding var confictAlterMessage: ShortcutConfictAlertMessage

func recordViewShouldBeginRecording(_: KeyHolder.RecordView) -> Bool {
true
Configuration.shared.isRecordingSelectTextShortcutKey = true
return true
}

func recordView(_: KeyHolder.RecordView, canRecordKeyCombo _: Magnet.KeyCombo) -> Bool {
true
}

func recordViewDidEndRecording(_: RecordView) {}
func recordViewDidEndRecording(_: RecordView) {
Configuration.shared.isRecordingSelectTextShortcutKey = false
}

func recordView(_ recordView: RecordView, didChangeKeyCombo keyCombo: KeyCombo?) {
if let key = keyCombo {
Expand All @@ -103,6 +106,7 @@ extension KeyHolderWrapper {
message: message
)
recordView.clear()
HotKeyCenter.shared.unregisterHotKey(with: type.rawValue)
return
}
} else { // clear shortcut
Expand Down

0 comments on commit 838b1d3

Please sign in to comment.