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: Mouse entering/leaving a window surface



Thanks a lot..
It works as expected , excepted that, as Philips says, this does not include the window title bar.


HIViewTrackingAreaRef() does not complain when I attach a tracking area to the RootView .
As the root view represents the whole window frame and is also a HiViewRef, it is not clear why the area tracking mechanism does not work on the root view;


Perhaps Eric (hello, Eric !.....)  could put some light no this..

Thank you

JP



Le 13 juin 07 à 07:56, Philip Aker a écrit :

On 2007-06-12, at 20:19:21, Turbo3D wrote:

How can I get events that tell when the mouse enter or leave a window surface (Carbon) ?
I tried to attach a handle on the window root control.., but the handler is never called ...

I don't know if it suits your purpose (doesn't do the title bar area), but installing a tracking area on the content view works. Something like this:


OSStatus HIView_InstallTrackingArea( HIViewRef theView ) {

OSStatus err = noErr;
HIViewTrackingAreaRef track_area = NULL;
EventTypeSpec kTrackEvents[] = {{kEventClassControl, kEventControlTrackingAreaEntered}, {kEventClassControl, kEventControlTrackingAreaExited}};

if( err == noErr ) {
err = HIViewNewTrackingArea( theView, NULL, 0, &track_area );
}
if( err == noErr ) {
err = InstallControlEventHandler( theView, TrackEventHandler, GetEventTypeCount( kTrackEvents ), kTrackEvents, theView, NULL );
}

return err;
}



OSStatus TrackEventHandler( EventHandlerCallRef theCallRef, EventRef ioEvent, void *theData ) {

OSStatus res = eventNotHandledErr;
UInt32 evcl= GetEventClass( ioEvent );
UInt32 evid = GetEventKind( ioEvent );

switch( evcl ) {
case kEventClassControl: {
switch( evid ) {
case kEventControlTrackingAreaEntered: {
res = SetThemeCursor( kThemeCrossCursor );
break;
}
case kEventControlTrackingAreaExited: {
res = SetThemeCursor( kThemeArrowCursor );
break;
}
}
}
}

return res;
}



HIViewRef content = NULL;
err = HIViewFindByID( HIViewGetRoot( window ), kHIViewWindowContentID, &content );
err = HIView_InstallTrackingArea( content );




_______________________________________________ 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: 
 >Mouse entering/leaving a window surface (From: Turbo3D <email@hidden>)
 >Re: Mouse entering/leaving a window surface (From: Philip Aker <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.