Skip to content

Commit

Permalink
Fix tap gesture on macOS Ventura
Browse files Browse the repository at this point in the history
  • Loading branch information
zenangst committed Dec 5, 2023
1 parent 2f3bdfa commit a1b6b74
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
13 changes: 10 additions & 3 deletions App/Sources/UI/Views/ContentListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,16 @@ struct ContentListView: View {
.contextMenu(menuItems: {
contextualMenu(element.id)
})
.onTapGesture {
onTap(element)
}
.focusable($focus, as: .element(element.id)) {
if let keyCode = LocalEventMonitor.shared.event?.keyCode, keyCode == kVK_Tab,
let lastSelection = contentSelectionManager.lastSelection,
let match = publisher.data.first(where: { $0.id == lastSelection }) {
focus = .element(match.id)
} else {
contentSelectionManager.handleOnTap(publisher.data, element: element)
debounceSelectionManager.process(.init(workflows: contentSelectionManager.selections,
groups: groupSelectionManager.selections))
onTap(element)
proxy.scrollTo(element.id)
}
}
Expand Down Expand Up @@ -196,6 +197,12 @@ struct ContentListView: View {
}
}

private func onTap(_ element: ContentViewModel) {
contentSelectionManager.handleOnTap(publisher.data, element: element)
debounceSelectionManager.process(.init(workflows: contentSelectionManager.selections,
groups: groupSelectionManager.selections))
}

@ViewBuilder
private func contextualMenu(_ selectedId: ContentViewModel.ID) -> some View {
Button("Duplicate", action: {
Expand Down
23 changes: 17 additions & 6 deletions App/Sources/UI/Views/GroupsListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,19 @@ struct GroupsListView: View {
let match = publisher.data.first(where: { $0.id == lastSelection }) {
focus = .element(match.id)
} else {
selectionManager.handleOnTap(publisher.data, element: group)
confirmDelete = nil
debounceSelectionManager.process(.init(groups: selectionManager.selections))
onTap(group)
}
}
.onTapGesture(count: 2, perform: {
onAction(.openScene(.editGroup(group.id)))
})
.gesture(
TapGesture(count: 1)
.onEnded { _ in
onTap(group)
}
.simultaneously(with: TapGesture(count: 2)
.onEnded { _ in
onAction(.openScene(.editGroup(group.id)))
})
)
}
.onCommand(#selector(NSResponder.insertTab(_:)), perform: {
appFocus.wrappedValue = .workflows
Expand Down Expand Up @@ -110,6 +115,12 @@ struct GroupsListView: View {
}
}

private func onTap(_ element: GroupViewModel) {
selectionManager.handleOnTap(publisher.data, element: element)
confirmDelete = nil
debounceSelectionManager.process(.init(groups: selectionManager.selections))
}

func confirmDeleteView(_ group: GroupViewModel) -> some View {
HStack {
Button(action: { confirmDelete = nil },
Expand Down

0 comments on commit a1b6b74

Please sign in to comment.