Re: Position of the mouse
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.