• 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: NSView doesnt receive mouseMoved events?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSView doesnt receive mouseMoved events?


  • Subject: Re: NSView doesnt receive mouseMoved events?
  • From: Jens Bauer <email@hidden>
  • Date: Tue, 28 Jan 2003 11:32:54 +0100

Hi all,

in my window's awakeFromNib I have the following...

- (void)awakeFromNib
{
[self setAcceptsMouseMovedEvents:YES];
}

I also have this method implemented:

- (void)mouseMoved:(NSEvent *)event
{
fprintf(stderr, "[myWindow mouseMoved:event]\n");
}


-But for some reason, mouseMoved only gets called when the button is *not* held down!

Is it possible to get mouseMoved events, even when the mouse button is held down?


On Tuesday, Jan 28, 2003, at 06:00 Europe/Copenhagen, Henry McGilton wrote:

On Friday, January 24, 2003, at 03:51 AM, mw wrote:

I'm not sure, but I think I had to deal with this too. You have to set up a
tracking rectangle (NSTrackingRect, I believe. It is a structure, not a
class) in the view which will report mouse events inside the tracking rect,
such as mouseEntered, mouseExited, mouseUp, mouseDown, mouseMoved, etc.

See Apple's docs on how to set up tracking rectangles in NSView subclasses.

mw


On 1/24/03 3:14 AM, "Sascha Kujawa" <email@hidden> wrote:

Heya,

I am trying to find out why my subclassed NSView does not receive
mouseMoved events. Others like mouseDown work fine.

Of course I told it's window setAcceptsMouseMovedEvents:YES
but my subclassed NSView still does not receive mouseMoved
events.

You don't *have* to use tracking rectangles, although that is
one way.

This topic is covered in Cocoa Programming (thank you chaps for
saving me one hell of a lot of time on this topic). They detail
four conditions that must be met:

o you must have sent a setAcceptsMouseMovedEvents:YES to
the view's window,
o the application containing the view must be the active
application,
o the view's window must be the key window,
o the view must be the first responder.

The AppKit documentation is somewhat weak in describing these
and other such interactions.


Love,
Jens
_______________________________________________
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: NSView doesnt receive mouseMoved events?
      • From: Sascha Kujawa <email@hidden>
References: 
 >Re: NSView doesnt receive mouseMoved events? (From: Henry McGilton <email@hidden>)

  • Prev by Date: Re: cocoa-dev digest, Vol 2 #1867 - 14 msgs
  • Next by Date: Re: NSView doesnt receive mouseMoved events?
  • Previous by thread: Re: NSView doesnt receive mouseMoved events?
  • Next by thread: Re: NSView doesnt receive mouseMoved events?
  • Index(es):
    • Date
    • Thread