• 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
Finding top most window/panel the cursor is currently hovering over
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Finding top most window/panel the cursor is currently hovering over


  • Subject: Finding top most window/panel the cursor is currently hovering over
  • From: Development <email@hidden>
  • Date: Wed, 19 Aug 2009 15:33:13 -0400

Can anyone tell me how to calculate what window the cursor is currently hovering over, at any given moment?

This sounds like a very simple bit of code, but it has stumped me and a number of other developer friends.

My application has document windows and panels. One the panel is a Result Bar, that displays information based on the cursor location on various panels/document windows (usually the mouse is over a custom view on a document or on a panel). Most of the time enterMouse & exitMouse methods are enough to display the correct information, but occasionally the application status changes on some level, and I need to update the information in the Results bar.

To do this, I want to take the cursor current location (in screen coordinates based on [NSEvent mouseLocation], find the top most window/ panel that the cursor is on top of (taking into account overlapping window/panels), then convert the screen coordinates into window coordinates (or simply use [NSEvent mouseLocationOutsideOfEventStream] to find the point in mouse coordinates). With this point, I call the hitTest: method for the windows Content view, and I know which custom view I am over, and call update the Result Bar.

My problem is I can not find a way to determine which window the cursor is over! There is no hitTest: type of method to be called on the NSApp level to return which window is hit. The Cocoa OS must be doing this for all the mouse Down and Up events, but there is no published call.

At first, I tried to cycle through the [NSApp windows] list, but this list does not take into account window ordering. Then I tried to use the [NSApp orderedWindow] list, but that list does not include panels (which my application uses heavily). There is no other calls to determine the window ordering that I can find. I am about to try using the [NSApplication makeWindowsPerform:inOrder:] method, passing it a custom method that I added using a category to all Windows, but again I am not sure the Panels are passed this call.

Does anyone have a suggestion?

Steve
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Core Animation + Garbage Collection
  • Next by Date: Bug in NSTableView handling with Snow Leopard
  • Previous by thread: Re: Statements in Replaced Method execute out of sequence - How?
  • Next by thread: Bug in NSTableView handling with Snow Leopard
  • Index(es):
    • Date
    • Thread