Skip to content

Instantly share code, notes, and snippets.

View vsameer's full-sized avatar
🎯
Focusing

Sameer Vartak vsameer

🎯
Focusing
View GitHub Profile
@lattner
lattner / TaskConcurrencyManifesto.md
Last active June 17, 2025 04:35
Swift Concurrency Manifesto
@importRyan
importRyan / whenHovered.md
Last active June 28, 2025 09:03
Reliable SwiftUI mouse hover

Reliable mouseEnter/Exit for SwiftUI

Kapture 2021-03-01 at 14 43 39

On Mac, SwiftUI's .onHover closure is not always called on mouse exit, particularly with high cursor velocity. A grid of targets or with finer target shapes will often have multiple targets falsely active after the mouse has moved on.

It is easy to run back to AppKit's safety. Below is a SwiftUI-like modifier for reliable mouse-tracking. You can easily adapt it for other mouse tracking needs.

import SwiftUI
@ABridoux
ABridoux / WindowPosition.swift
Last active June 3, 2025 08:25
Logic to easily set a NSWindow's origin horizontally and vertically in a screen (AppKit and SwiftUI)
// Free to use
// Written by Alexis Bridoux - https://github.com/ABridoux
import AppKit
#if canImport(SwiftUI)
import SwiftUI
#endif
// MARK: Model