Detect user-list double-click manually instead of via SwiftUI gestures#31
Merged
Detect user-list double-click manually instead of via SwiftUI gestures#31
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
simultaneousGesture(TapGesture(count: 2))didn't fully resolve the click-deferral.simultaneousGesture, SwiftUI's gesture resolver still has to wait the OS double-click window before committing a count=1 tap, because the count=2 recognizer is a competing alternative. On busy channels every MODE / AWAY update re-renders rows, and a row that re-renders mid-deferral loses the gesture state — so the click silently drops.onTapGesture(single-tap, no deferral) and detect double-clicks manually by checking whether the same user was tapped withinNSEvent.doubleClickInterval. Mirrors whatNSTableViewdoes natively.Changes
Sources/Brygga/Views/ContentView.swift—UserListView:@State private var lastClickedID: User.ID?and@State private var lastClickedAt: Date?..simultaneousGesture(TapGesture(count: 2)...)with.onTapGesture { handleClick(on: user) }.handleClick(on:)that selects on first click, opens PM on a second click withinNSEvent.doubleClickIntervalon the same row, and clears the double-click state on a successful PM open or channel switch..onChange(of: channel.id)now also resets the double-click tracker so a click in one channel can't accidentally count as the first half of a double-click after switching channels.Test plan
swift build— passesswift test— 131 tests passswiftformat --lint .— cleanNSEvent.doubleClickIntervalhonors a non-default System Settings → Accessibility → Pointer Control double-click speed.Risk / rollback