Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / CodeWarrior / July 2004



Tip: Looking for answers? Try searching our database.

HIToolbar - no clicks :-(

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Martin Knelleken - 29 Jul 2004 11:28 GMT
Hi all,

I have got an application which is based on Powerplants
LDocApplication and I want to use the HIToolbar
(CW 9.2 on MacOS X 10.3 on G5).

Ok, I looked into the sample code on /Developer/Examples
and have just copied same pieces into my code.

Now the toolbar appears and there are same items in it.
Great!
Furthermore I can get the configuration sheet and I can
put other items into the bar. Even great.

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.

What is missing here?

Do I need to change my application to a subclass
of LCarbonApp?

Or do I need a special handler?
(I tried out the handlers from the sample code without
success).

By the way: The hide/show toolbar button works.

Thanks for all help.

Kind regards

Martin
David Dunham - 29 Jul 2004 16:21 GMT
> 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 (but
you don't have to change your application, simply add handlers).

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 - 29 Jul 2004 18:28 GMT
> > 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.