• 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: Remi <email@hidden>
  • Date: Mon, 31 Mar 2003 18:17:18 +0300

On Monday, March 31, 2003, at 04:29 PM, Quentin Mathi wrote:

Le lundi, 31 mars 2003, ` 14:18 Europe/Paris, j o a r a icrit :

On Monday, Mar 31, 2003, at 14:04 Europe/Stockholm, Quentin Mathi wrote:

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

Polling? That must be a bad way to solve this problem. What about using tracking rects:

<file:///Developer/Documentation/Cocoa/TasksAndConcepts/ ProgrammingTopics/BasicEventHandling/Tasks/>> HandlingMouseTracking.html>

It should work fine for this purpose.

Doesn't work when the view isn't first responder

I take also a look in the Cocoa programming book and they propose the same solution; but I agree with you, Cocoa should be able to handle that more elegantly.



I have been fighting with this issue a while ago.
These are my solutions:

1. You can make the view first responder at mouseEntered.

2. Also, you can intercept ANY message at application level (subclass NSApplication) and you will see that all messages are going through

- (void)sendEvent:(NSEvent *)anEvent

So, you can do something like this :

if ([anEvent type] == NSMouseMoved)
{
// if it is a mouse moved, maybe it is over your view and the view is not first respoder
// make the view first responder
.....
}
[super sendEvent:anEvent];
}
}

It's dirty, but it works.
Good luck !

Cristian
_______________________________________________
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.

References: 
 >Re: Position of the mouse (From: Quentin Mathé <email@hidden>)

  • Prev by Date: Re: Position of the mouse
  • Next by Date: Re: NSView setVisible: method -- NOT
  • Previous by thread: Re: Position of the mouse
  • Next by thread: Scrolling a NSScrollView by code
  • Index(es):
    • Date
    • Thread