• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Current mouse screen?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Current mouse screen?


  • Subject: Re: Current mouse screen?
  • From: John Randolph <email@hidden>
  • Date: Mon, 19 Apr 2004 16:44:44 -0700

On Apr 18, 2004, at 2:42 AM, M. Uli Kusterer wrote:

At 10:51 Uhr -0700 17.04.2004, Shaun Wexler wrote:
On Apr 17, 2004, at 10:16 AM, Ondra Cada wrote:

Anybody knows how to find the screen the mouse is currently on? The
position is easy ([NSEvent mousePosition]), but I did not succeed to
find the screen...

NSPoint mouseLoc = [NSEvent mouseLocation];
NSEnumerator *screenEnum = [[NSScreen screens] objectEnumerator];
NSScreen screen;
while ((screen = [screenEnum nextObject]) && !NSMouseInRect(mouseLoc, [screen frame], NO));

Usual disclaimers apply; written in Mail.app.

That should be NSPointInRect() instead of NSMouseInRect(), AFAIK.

Actually, NSMouseInRect() still exists.. It accounts for flipped coordinate spaces, which NSPointInRect() doesn't.

-jcr
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Current mouse screen?
      • From: "Louis C. Sacha" <email@hidden>
References: 
 >Current mouse screen? (From: Ondra Cada <email@hidden>)
 >Re: Current mouse screen? (From: Shaun Wexler <email@hidden>)
 >Re: Current mouse screen? (From: "M. Uli Kusterer" <email@hidden>)

  • Prev by Date: Re: Application Icon
  • Next by Date: Re: Line/page scrolling an NSScrollView
  • Previous by thread: Re: Current mouse screen?
  • Next by thread: Re: Current mouse screen?
  • Index(es):
    • Date
    • Thread