From a1b6b747ce0af4f3efc604796b2fc33f97990a07 Mon Sep 17 00:00:00 2001 From: Christoffer Winterkvist Date: Tue, 5 Dec 2023 11:31:24 +0100 Subject: [PATCH] Fix tap gesture on macOS Ventura --- App/Sources/UI/Views/ContentListView.swift | 13 +++++++++--- App/Sources/UI/Views/GroupsListView.swift | 23 ++++++++++++++++------ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/App/Sources/UI/Views/ContentListView.swift b/App/Sources/UI/Views/ContentListView.swift index 35d6aa19..49060337 100644 --- a/App/Sources/UI/Views/ContentListView.swift +++ b/App/Sources/UI/Views/ContentListView.swift @@ -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) } } @@ -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: { diff --git a/App/Sources/UI/Views/GroupsListView.swift b/App/Sources/UI/Views/GroupsListView.swift index 8e85b362..1df05a27 100644 --- a/App/Sources/UI/Views/GroupsListView.swift +++ b/App/Sources/UI/Views/GroupsListView.swift @@ -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 @@ -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 },