11import SwiftUI
2- import AppKit
32
43struct ProfileListView : View {
54 @EnvironmentObject var profileManager : ProfileManager
6- @State private var doubleClickMonitor : Any ?
75
86 var body : some View {
97 VStack ( spacing: 0 ) {
@@ -18,17 +16,10 @@ struct ProfileListView: View {
1816 . padding ( . vertical, 8 )
1917
2018 List ( profileManager. filteredProfiles, selection: $profileManager. selectedProfiles) { profile in
21- ProfileRow ( profile: profile)
19+ ProfileRow ( profile: profile, onDoubleClick: {
20+ profileManager. connectToProfile ( profile)
21+ } )
2222 . tag ( profile)
23- . background (
24- Color . clear
25- . onAppear {
26- // Set up double-click monitoring when a row appears
27- if doubleClickMonitor == nil {
28- setupDoubleClickMonitor ( )
29- }
30- }
31- )
3223 . contextMenu {
3324 if profileManager. selectedProfiles. contains ( profile) && profileManager. selectedProfiles. count > 1 {
3425 // Multi-selection context menu
@@ -158,36 +149,12 @@ struct ProfileListView: View {
158149 }
159150 }
160151 }
161- . onDisappear {
162- // Clean up the event monitor
163- if let monitor = doubleClickMonitor {
164- NSEvent . removeMonitor ( monitor)
165- doubleClickMonitor = nil
166- }
167- }
168- }
169-
170- private func setupDoubleClickMonitor( ) {
171- doubleClickMonitor = NSEvent . addLocalMonitorForEvents ( matching: . leftMouseDown) { event in
172- if event. clickCount == 2 {
173- // Double-click detected
174- if let firstProfile = profileManager. selectedProfiles. first {
175- DispatchQueue . main. async {
176- if profileManager. selectedProfiles. count == 1 {
177- profileManager. connectToProfile ( firstProfile)
178- } else {
179- profileManager. connectToProfiles ( Array ( profileManager. selectedProfiles) , mode: . tabs)
180- }
181- }
182- }
183- }
184- return event
185- }
186152 }
187153}
188154
189155struct ProfileRow : View {
190156 let profile : SSHProfile
157+ var onDoubleClick : ( ( ) -> Void ) ? = nil
191158
192159 var body : some View {
193160 HStack {
@@ -213,6 +180,10 @@ struct ProfileRow: View {
213180 Spacer ( )
214181 }
215182 . padding ( . vertical, 4 )
183+ . contentShape ( Rectangle ( ) )
184+ . onDoubleClick {
185+ onDoubleClick ? ( )
186+ }
216187 }
217188}
218189
0 commit comments