Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get a kEventMouseExited at the edge of a window



On Fri, 9 Mar 2007 11:07:43, John Stiles <email@hidden> wrote:

> On Mar 9, 2007, at 10:49 AM, Matthew Douglass wrote:
>
>>> My goal is to get a notification when the mouse leaves my window content
>>> region (in 10.3+).  I saw kEventMouseExited and decided to try to use that.
>>> I added a call to CreateMouseTrackingRegion, passing in the region returned
>>> by GetWindowRegion(kWindowContentRegion) and
>>> kMouseTrackingOptionsGlobalClip.  But even after realizing I needed to call
>>> SetMouseTrackingRegionEnabled(true), I still never get any events.
>>> 
>>> As an experiment, I created a Rect slightly smaller than the size of my
>>> window (about 10 pixels on each side) and passed that in to
>>> CreateMouseTrackingRegion with kMouseTrackingOptionsLocalClip.  After doing
>>> that I started to get kEventMouseExited events.  However, I noticed that if
>>> I moved the mouse very quickly (fast enough that I don't get mouse moved
>>> events inside that 10 pixel boundary), then I don't get kEventMouseExited.
>>> 
>>> So I need some way to get a notification when the mouse is leaving the
>>> content region of my window - what other options are there?
>>
>> So why is it inevitable that I always send these emails and then
>> have a brainstorm.  I realized I could catch kEventMouseMoved at
>> the application level and then just check if kEventParamWindowRef
>> is my window or not.
>
> That will work, but it will be a firehose of events :)

Unless mouse moved events are sent with kEventTargetSendToAllHandlers
option (which I believe is not the case, otherwise it would be mentioned
in the CarbonEvents.h), the mouse moved handler installed on a particular
window might interrupt the event flow by means of returning noErr from
the handler. Won't that be a problem? I haven't tried using event dispatcher
target in this context but maybe it's more appropriate.

>> Sorry for the noise,

Good question, actually. BTW, future versions of Mac OS might deprecate
MouseTrackingRegions in favor of HIView-based tracking areas.

Mike
[Available for hire. Resume on request.]


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

References: 
 >Re: How to get a kEventMouseExited at the edge of a window (From: John Stiles <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.