How to Make Double Click work on a NavigationLink (SwiftUI)?

Mark van Wijnen
4 min readJul 16, 2022
Photo by Alex Bachor on Unsplash

It’s actually ridiculous that this story needs to be written. Something as basic as detecting a double mouse click on a NavigationLink should be as easy as using the .onTapGesture(count: 2) {} event modifier. However if you arrived at this story there is a great chance you will have noticed that it doesn’t work as you would expect it and you are eager to find a workaround. I am here to tell you that there is and I am going to show you how.

Reproduce the Problem

Xcode 14 (beta 3)
macOS Ventura (13)

Expected Results

I would expect that when I click anywhere in the row the item will be selected. When I double click on the row it would show the message Double Click Detected in the console.

Actual Results

When I click on the text (1) the item will not get selected. When I double click on the text the message Double Click Detected is shown in the…

--

--

Mark van Wijnen

macOS/iPadOS/iOS/watchOS/visionOS developer and SwiftUI enthousiast. “Stay Hungry, Stay Foolish!” — Steve Jobs