• 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: Another Logic question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Another Logic question
      • From: Howard Moon <email@hidden>
References: 
 >Another Logic question (From: Howard Moon <email@hidden>)

  • Prev by Date: Another Logic question
  • Next by Date: AUCarbonViewControl::HandleEvent logic...
  • Previous by thread: Another Logic question
  • Next by thread: Re: Another Logic question
  • Index(es):
    • Date
    • Thread