Custom Control/AUCarbonViewBase woes
Custom Control/AUCarbonViewBase woes
- Subject: Custom Control/AUCarbonViewBase woes
- From: Art Gillespie <email@hidden>
- Date: Tue, 24 Sep 2002 20:57:42 -0400
I'm attempting to create a custom control and add it to
AUCarbonViewBase.mCarbonPane via AUCarbonViewBase::EmbedControl()
It works great except that no matter what I do, I don't seem to be
receiving
kEventControlTrack messages in my CustomControlHandler proc...
I'm receiving kEventControlDraw, kEventControlClick, kEventControlHit,
etc. but not kEventControlTrack. Here's where I create the custom
control and embed it in AUCarbonViewBase:
ToolboxObjectClassRef customControl;
EventTypeSpec CEventList[] = {{kEventClassControl,
kEventControlDraw},
{kEventClassControl, kEventControlHitTest},
{kEventClassControl, kEventControlTrack},
{kEventClassControl, kEventControlClick}
};
RegisterToolboxObjectClass (CFSTR ("com.Moof.MyApp.cntrl"),
NULL, 4, CEventList,
NewEventHandlerUPP (MyCustomControlHandler),
NULL, &customControl);
ControlDefSpec myCustomControlSpec;
ControlRef myControl;
Rect controlBounds = {(int)yoffset, (int)xoffset, (int)yoffset +
480, (int)xoffset + 640};
myCustomControlSpec.defType = kControlDefObjectClass;
myCustomControlSpec.u.classRef = customControl;
CreateCustomControl (mCarbonWindow, &controlBounds,
&myCustomControlSpec,
NULL, &myControl);
EmbedControl(myControl);
And MyCustomControlHandler looks like this (abbreviated for the
bandwidth challenged):
....
whatHappened = GetEventKind (theEvent);
switch (whatHappened)
{
case kEventControlDraw:
<snip> //works fine
result = noErr;
break;
case kEventControlTrack: //doesn't appear to get called.
SysBeep(1);
GetMouse(&p);
GetPort(&thePort);
RGBForeColor(&black);
LineTo(p.h, p.v);
printf("#&*!&$#\n"); //expert new england-style debugging
techniques
result = noErr;
break;
case kEventControlHitTest:
<snip>
result = noErr; //works
break;
case kEventControlClick:
<snip> //works
result = noErr;
break;
}
I realize that this area of AU is undocumented, so I'm on my own, but I
was wondering if anyone had any ideas regarding:
a) Why this doesn't work - I gather that since toolbox native controls
that require this behavior work (e.g. ControlSlider) that I'm doing
something stupid... I've looked for sample code for custom controls at
the ADC but didn't find any that implemented the kEventControlTrack
handler. (I even searched on Google some, Bill :D)
b) Whether this is the best way to go about creating custom gui widgets
for AU or if I should be barking up the HIToolbox instead and
inheriting from HIView (which doesn't appear to be a class at all, but
a collection of constants).
Thanks,
Art
>
>0xBA
_______________________________________________
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.