Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Creating Your Own Events

In addition to processing and dispatching events, the Carbon Event Manager also lets you create your own events. You may want to create your own custom events, or you might want to reproduce standard events.

You create an event using the CreateEvent function:

OSStatus CreateEvent( CFAllocatorRef inAllocator<null>,
                    UInt32 inClassID, UInt32 kind,EventTime when,
                    EventAttributes flags, EventRef* outEvent);

If your event requires additional information, you can add data by calling SetEventParameter. If you are creating custom events, you need to define constants for your parameter names and types if they don’t already exist. For example, if you define a parameter for a screen location, you may want to define a new parameter name, but you can probably still use typeQDPoint for the parameter type.

Once you create an event, you need to send it to a handler. There are two basic methods for doing so:

Note that if you send an event to the standard toolbox dispatcher and it does not recognize it (that is, it’s a custom event), then it will dispatch the event to the application event target (unless you specified an event target in your custom event using the kEventParamPostTarget parameter).

If you want to create and process command events, the Carbon Event Manager provides the function ProcessHICommand:

OSStatus ProcessHICommand (const HICommand* inCommand);

When you pass an Command ID to ProcessHICommand, it builds a kEventCommandProcess event containing the ID and then dispatches the event to either



< Previous PageNext Page > Hide TOC


Last updated: 2005-07-07




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice