Re: Another Logic question
Re: Another Logic question
- Subject: Re: Another Logic question
- From: Urs Heckmann <email@hidden>
- Date: Thu, 5 Dec 2002 19:12:09 +0100
Am Donnerstag, 05.12.02, um 18:34 Uhr (Europe/Berlin) schrieb Howard
Moon:
Hi again...
I'm modifying the Pan sample just to familiarize myself with Logic
and Audio Units, and noticed a strange difference between running
under Audio Unit Hosting and under Logic Audio. My drawing if fine,
but my mouse tracking is offset by the difference between the Mixer
window and my Pan window. Obviously, I need to subtract that
difference from the mouse coordinates, but how do I get the Mixer
window port handle in order to call GetPortBounds on it and make my
subtraction? Thanks...
Howard
Hi,
here's what I do (snipped a bit and sorry for bandwidth):
static pascal OSStatus CAUGuiControlHandler ( EventHandlerCallRef
myHandler, EventRef theEvent, void* userData )
{
#pragma unused (myHandler )
OSStatus result = eventNotHandledErr;
UInt32 whatHappened;
GrafPtr thePort;
CGrafPtr windowPort;
WindowRef theWindow;
ControlRef theControl;
Rect controlBounds;
Rect portBounds;
Rect globalBounds; // Window Content Region...
CGContextRef context;
Point P;
int doDaTrack = 1;
UInt32 modifiers;
bool with_option, with_shift;
whatHappened = GetEventKind ( theEvent );
GetEventParameter ( theEvent, kEventParamDirectObject,
typeControlRef, NULL, sizeof( ControlRef ), NULL, &theControl );
GetControlBounds ( theControl, &controlBounds );
theWindow = GetControlOwner ( theControl );
GetWindowBounds( theWindow, kWindowGlobalPortRgn, &globalBounds);
CAUGuiMan* theChief = (CAUGuiMan*)userData;
CAUGuiCtrl* theCtrl = NULL;
if ( theChief != NULL )
{
theCtrl = theChief->getCtrlByControlRef ( theControl ); }
if ( theCtrl != NULL )
{
//printf ("Control exists!\n");
switch ( whatHappened )
{
case kEventControlDraw:
<snipped>
case kEventControlTrack:
case kEventControlClick:
modifiers = GetCurrentEventKeyModifiers();
with_option = modifiers & optionKey ? true : false;
with_shift = modifiers & shiftKey ? true : false;
//GetMouse ( &P );
GetGlobalMouse ( &P );
P.h -= controlBounds.left + globalBounds.left;
P.v -= controlBounds.top + globalBounds.top;
theCtrl->mouseDown( &P, with_option, with_shift );
MouseTrackingResult outResult;
while ( doDaTrack )
{
TrackMouseLocation (NULL, &P, &outResult);
GetGlobalMouse ( &P );
P.h -= controlBounds.left + globalBounds.left;
P.v -= controlBounds.top + globalBounds.top;
if ( outResult == kMouseTrackingMouseUp )
{
theCtrl->mouseUp( &P, with_option, with_shift );
doDaTrack = 0;
}
else
theCtrl->mouseTrack( &P, with_option, with_shift );
}
result = noErr;
break;
}
}
return ( result );
}
Basically, I grab global mouse coordinates and subtract
windowcoordinates + control coordinates. Seems to work in all known and
unknown apps.
Cheers,
;) Urs
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.