
Signature
David Dunham A Sharp, LLC
http://www.a-sharp.com/
"I say we should listen to the customers and give them what they want."
"What they want is better products for free." --Scott Adams
> > But it does not recognize mouse clicks at all :-(
> > The items keep unchanged (i.e. they do not invert)
> > when I click on them and so I do not get any message
> > at all.
>
> I don't think you can use a toolbar without handling Carbon Events
Yes. Thats clear.
> (but you don't have to change your application, simply add handlers).
simply ... mhmh
But which one?
The sample code works with 3 handlers.
I figured out, that the following one is called when a toolbar
item is clicked:
EventTypeSpec kEvents[] = { { kEventClassCommand,
kEventCommandProcess } };
InstallApplicationEventHandler( AppHandler, GetEventTypeCount(
kEvents ), kEvents, 0, NULL );
where AppHandler is
OSStatus AppHandler( EventHandlerCallRef inCallRef,
EventRef inEvent, void* inUserData )
{
HICommand command;
OSStatus result = eventNotHandledErr;
GetEventParameter( inEvent, kEventParamDirectObject,
typeHICommand, NULL, sizeof( HICommand ),
NULL, &command );
// Do something useful here
return result;
}
When I use this in my code, the handler is called by several commands
but NOT when toolbar items are clicked.
Strange ...
Kind regards
Martin
David Dunham - 30 Jul 2004 06:07 GMT
> When I use this in my code, the handler is called by several commands
> but NOT when toolbar items are clicked.
You may need to be the delegate for
static const EventTypeSpec kToolbarEvents[] = {
{ kEventClassToolbar, kEventToolbarGetDefaultIdentifiers },
{ kEventClassToolbar, kEventToolbarGetAllowedIdentifiers },
{ kEventClassToolbar, kEventToolbarCreateItemWithIdentifier }
};
I think more importantly, you need to have the standard handler in order
for your toolbar to work. And if you have a standard handler, you'll
need to override some of what it does in order for PowerPlant to work.

Signature
David Dunham A Sharp, LLC
http://www.a-sharp.com/
"I say we should listen to the customers and give them what they want."
"What they want is better products for free." --Scott Adams
Martin Knelleken - 30 Jul 2004 13:43 GMT
> You may need to be the delegate for
>
[quoted text clipped - 3 lines]
> { kEventClassToolbar, kEventToolbarCreateItemWithIdentifier }
> };
Yes, that was implemented. Otherwise the toobar would not be drawn.
> I think more importantly, you need to have the standard handler in order
> for your toolbar to work.
That was it!
Now I get the events properly.
> you'll need to override some of what it does in order for
> PowerPlant to work.
Yes, I see. But this will be not too hard.
Thanks a lot!
Kind regards
Martin