Skip to content

Commit

Permalink
Add repeated-press logic to cycle popup selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexis Gaziello committed Dec 26, 2024
1 parent 1c6f694 commit 54b7b60
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions Maccy/Extensions/Defaults.Keys+Names.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ extension Defaults.Keys {
static let pinTo = Key<PinsPosition>("pinTo", default: .top)
static let popupPosition = Key<PopupPosition>("popupPosition", default: .cursor)
static let popupScreen = Key<Int>("popupScreen", default: 0)
static let cyclePopUp = Key<Bool>("cyclePopUp", default: false)
static let previewDelay = Key<Int>("previewDelay", default: 1500)
static let removeFormattingByDefault = Key<Bool>("removeFormattingByDefault", default: false)
static let searchMode = Key<Search.Mode>("searchMode", default: .exact)
Expand Down
10 changes: 9 additions & 1 deletion Maccy/Observables/Popup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ class Popup {

init() {
KeyboardShortcuts.onKeyUp(for: .popup) {
self.toggle()
if Defaults[.cyclePopUp] {
if (AppState.shared.appDelegate?.panel.isPresented ?? false) {
AppState.shared.highlightNext()
} else {
self.open(height: self.height)
}
} else {
self.toggle()
}
}
}

Expand Down
12 changes: 10 additions & 2 deletions Maccy/Settings/GeneralSettingsPane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,16 @@ struct GeneralSettingsPane: View {

Settings.Section(label: { Text("Open", tableName: "GeneralSettings") }) {
KeyboardShortcuts.Recorder(for: .popup)
.help(Text("OpenTooltip", tableName: "GeneralSettings"))
}
.help(Text("OpenTooltip", tableName: "GeneralSettings"))
Defaults.Toggle(key: .cyclePopUp) {
Text("CyclePopUp", tableName: "GeneralSettings")
}
.onChange(refreshModifiers)
.fixedSize()
.padding(.leading, 10)
.help(Text("CyclePopUpHelp", tableName: "GeneralSettings"))
}

Settings.Section(label: { Text("Pin", tableName: "GeneralSettings") }) {
KeyboardShortcuts.Recorder(for: .pin)
.help(Text("PinTooltip", tableName: "GeneralSettings"))
Expand Down
2 changes: 2 additions & 0 deletions Maccy/Settings/en.lproj/GeneralSettings.strings
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
"Regex" = "Regular expressions";
"Mixed" = "Mixed";
"NotificationsAndSounds" = "Notifications and sounds 􀱁";
"CyclePopUp" = "Cycle selection on repeated press";
"CyclePopUpHelp" = "When enabled, pressing the 'Open' shortcut again will select the next item in the clipboard history.";

0 comments on commit 54b7b60

Please sign in to comment.