• 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: Position of the mouse
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Position of the mouse


  • Subject: Re: Position of the mouse
  • From: Quentin Mathé <email@hidden>
  • Date: Mon, 31 Mar 2003 14:04:26 +0200

Le jeudi, 27 mars 2003, ` 21:56 Europe/Paris, email@hidden a icrit :

On jeudi, mars 27, 2003, at 09:23 PM, Luca Torella wrote:

Hello,
I have a subclass of an NSView, and I want that, when the mouse is over the NSView, it writes the current position of the mouse (X,Y) in two NSTextView.
I tried to used the event -mouseMoved of NSResponder Class, but it doesn't work.
How can I write the position?

I've been playing with this and didn't find any good solution.

To make mouseMoved work you need to set the window to send mouseMoved message:

setAcceptsMouseMovedEvents:

And mouseMoved are only sent to the first responder.

This means that if you click on the window title bar in some cases, mouseMoved is not send anymore.

The solution is to poll periodically the mouse location with a timer.

The timer should execute the code :
NSPoint mouseLocation = [[view window] mouseLocationOutsideOfEventsStream];
if ([view mouse:mouseLocation inRect:[view frame]]) {
output = [view convertPoint:mouseLocation fromView:nil];
// now, here is the code to show the mouse location
}

Quentin.

--
Quentin Mathi
email@hidden
_______________________________________________
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: Position of the mouse
      • From: j o a r <email@hidden>
References: 
 >Re: Position of the mouse (From: email@hidden)

  • Prev by Date: CFBundleTypeExtensions for folders?
  • Next by Date: Re: Position of the mouse
  • Previous by thread: Re: Position of the mouse
  • Next by thread: Re: Position of the mouse
  • Index(es):
    • Date
    • Thread