• 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: mouseMoved problems [SOLVED]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mouseMoved problems [SOLVED]


  • Subject: Re: mouseMoved problems [SOLVED]
  • From: Chris Meyer <email@hidden>
  • Date: Thu, 21 Mar 2002 12:36:11 -0800

Hi,

Just for the record I solved the problem (by examining the differences in the example pointed to by John Saccente - thanks!).

The problem seems to be that the setAcceptsMouseMovedEvents: method only works when the view is currently the first responder. That is why it doesn't work to setAcceptsMouseMovedEvents: in the initWithFrame: method or the viewDidMoveToWindow: method. In fact since it only works when the view is the first responder, the view must be set to accept first responder status too.

Once I added the methods below I got all of the mouseMoved: messages.

- (BOOL)acceptsFirstResponder
{
return YES;
}

- (BOOL)becomeFirstResponder
{
[[self window] setAcceptsMouseMovedEvents: YES];
return YES;
}

- (BOOL)resignFirstResponder
{
[[self window] setAcceptsMouseMovedEvents: NO];
return YES;
}

Incidentally, Apple's documentation is incorrect and misleading. The documentation for acceptsFirstResponder is:

acceptsFirstResponder

- (BOOL)acceptsFirstResponder
Overridden by subclasses to return YES if the receiver can handle key events and action messages sent up the responder chain. NSResponder's implementation returns NO, indicating that by default a responder object doesn't agree to become first responder. Objects that aren't first responder can receive mouse event messages, but no other event or action messages.

The last sentence should probably read 'Objects that aren't first responder can receive mouse event messages except for mouseMoved:, but no other event or action messages.'

Chris

On Thursday, March 21, 2002, at 11:04 AM, Chris Meyer wrote:

Hi,

I have a custom view derived from NSView and I am trying to get mouseMoved events but I don't get any. I think I have set everything up properly. The following methods are defined in my custom view and when I click the mouse it prints out "YES" in the log window. I get the mouseDragged events just fine. But I never get a mouseMoved event.

Is someone out there successfully using mouseMoved events? Or are there any bugs with it anyone knows about? Does it look like I'm doing something obviously wrong?

I'm using 10.1.3 (5Q45) with Dec 2001 tools.

Thanks for any help,
Chris

- (void)mouseDown:(NSEvent *)theEvent
{
NSLog( [[self window] acceptsMouseMovedEvents] ? @"YES" : @"NO" );
}

- (void)mouseDragged:(NSEvent *)theEvent
{
NSLog( @"mouseDragged" );
}

- (void)mouseMoved:(NSEvent *)theEvent
{
NSLog( @"mouseMoved" );
}
_______________________________________________
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: mouseMoved problems [SOLVED]
      • From: John Saccente <email@hidden>
References: 
 >mouseMoved problems (From: Chris Meyer <email@hidden>)

  • Prev by Date: Re: Need clarification on categories
  • Next by Date: Re: Using NSURL
  • Previous by thread: Re: mouseMoved problems
  • Next by thread: Re: mouseMoved problems [SOLVED]
  • Index(es):
    • Date
    • Thread