Skip to content

Detect user-list double-click manually instead of via SwiftUI gestures#31

Merged
buggerman merged 1 commit intomainfrom
userlist-manual-double-click
Apr 26, 2026
Merged

Detect user-list double-click manually instead of via SwiftUI gestures#31
buggerman merged 1 commit intomainfrom
userlist-manual-double-click

Conversation

@buggerman
Copy link
Copy Markdown
Owner

Summary

  • Single-click on a nick in the right-side user list was still flaky after Fix flaky single-click selection in the user list #22simultaneousGesture(TapGesture(count: 2)) didn't fully resolve the click-deferral.
  • Root cause: even with 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.
  • Fix: drop SwiftUI's count=2 gesture entirely. Attach only an onTapGesture (single-tap, no deferral) and detect double-clicks manually by checking whether the same user was tapped within NSEvent.doubleClickInterval. Mirrors what NSTableView does natively.

Changes

  • Sources/Brygga/Views/ContentView.swiftUserListView:
    • Adds @State private var lastClickedID: User.ID? and @State private var lastClickedAt: Date?.
    • Replaces .simultaneousGesture(TapGesture(count: 2)...) with .onTapGesture { handleClick(on: user) }.
    • New private handleClick(on:) that selects on first click, opens PM on a second click within NSEvent.doubleClickInterval on 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 — passes
  • swift test — 131 tests pass
  • swiftformat --lint . — clean
  • Manual:
    • Single-click any nick — row highlights immediately, every time, even on a busy channel with frequent MODE / AWAY traffic.
    • Double-click a nick — opens / focuses the PM tab.
    • Click nick A, wait ~1 s, click nick B — both selections register cleanly; no PM opens.
    • Click nick A, then within ~250 ms click nick A again — PM opens.
    • Right-click — context menu opens regardless of selection.
    • Switch channels mid-double-click sequence — the half-click doesn't carry over.
    • Verify NSEvent.doubleClickInterval honors a non-default System Settings → Accessibility → Pointer Control double-click speed.

Risk / rollback

  • Pure view-local logic change. No model or persistence touch.
  • Worst case: a user with an extremely fast manual double-click cadence (< system interval) could see two single-click selections instead of a PM. Easy follow-up: clamp the interval to a minimum of e.g. 100 ms.
  • Revert: this single commit.

@buggerman buggerman merged commit 48da982 into main Apr 26, 2026
1 check passed
@buggerman buggerman deleted the userlist-manual-double-click branch April 26, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant