Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonm23/465d00708d67a069e902645a3d16800e to your computer and use it in GitHub Desktop.
Save jasonm23/465d00708d67a069e902645a3d16800e to your computer and use it in GitHub Desktop.
//
// NSScreen+currentScreenForMouseLocation.swift
// CutBox
//
import Cocoa
extension NSScreen {
static func currentScreenForMouseLocation() -> NSScreen? {
let mouseLocation = NSEvent.mouseLocation
return screens.first(where: { NSMouseInRect(mouseLocation, $0.frame, false) })
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment