• 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
Another newbie Q - tracking mouse position.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Another newbie Q - tracking mouse position.


  • Subject: Another newbie Q - tracking mouse position.
  • From: Rustam Muginov <email@hidden>
  • Date: Fri, 12 Sep 2003 13:14:46 +0400

Hello, Cocoa Developers.

First I'd like to thank all who answered to my question "is where Obj-C
analog for a C++ static data". I do appreciate all the answers.

Second, the over question.
I am developing a document-based application. Generaly, each document have
the window with 3 views, presenting different "projections" of 3D objects.
I would like to have the status line at the bottom of each window, where the
current mouse position would be shown.
For now, I've found three possibilities to implement this:

1) Install the NSTimer instance, periodicaly check with NSWindow's
-mouseLocationOutsideOfEventStream, check if coordinates are in one of the
views, and if yes - show them in the status line. Looks a bit weird method,
IMHO. Plus, I need to track then window going background, to stop the timer,
and restart it for any window going foreground.

2) Use the setAcceptsMouseMovedEvents: TRUE for the window, as it is adviced
in the documentation. I have found what this does not result for my views to
receive -mouseMoved message, until I am overriding the
-(BOOL)acceptsFirstResponder in my view and returning YES. Also, I am
receiveing the -mouseMoved even if mouse is moved outside the views - even
outside the window itself.
Also, for some reason, only one view do receive this message. I still can
not figure why.

3) Use the -addTrackingRect: owner: userData: assumeInside: to setup the
tracking rect. I did not make this work so far, just trying ot use this
approach.

A question: what would be most cocoa-ish way yo implement tracking of mouse
location? Which approach (probably the over one exists?) is the most
consistient and speedwise optimal? What are any possible traps which should
be avoiided with such approach?

Thanks all in advance.
_______________________________________________
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.

  • Prev by Date: Getting the main run loop to call a selector
  • Next by Date: Re: Getting the main run loop to call a selector
  • Previous by thread: Re: Getting the main run loop to call a selector
  • Next by thread: Re: splash screen
  • Index(es):
    • Date
    • Thread