Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Behavior of InstallEventHandler differs from Reference (10.3.9)




On Jun 30, 2006, at 7:06 PM, email@hidden wrote:

When the 2nd call succeeds with same handler/spec but different data, can you confirm that the handler begins to receive the *new* data and not the old data?

No, because that's not how it works. It's not really an issue of new data versus old data. Handlers are installed on a stack. The last one installed is the first one to be called, but all could potentially be called in succession. In practice the "data" is usually a pointer of some sort, such as a class object pointer in C++, a ControlRef, or something of that ilk. For example, I have windows that install an event handler on the application event target for kEventVolumeMounted. The "data" is a pointer to the window's C++ class wrapper, and the handler calls a member function in the window's class when that event is received. This particular handler always returns eventNotHandledErr so the handler will be called for every window that installed it.


Larry


Kevin G.

In all the following, I am using 1 EventSpec per call to InstallEventHandler
If I register the same handler with the same EventSpec same target, but different user data, it succeeds.
If I register the same handler with two different EventSpecs, but the same target and user data it fails with error eventHandlerAlreadyInstalledErr



The manual says this error should come from registering the same handler with the same EventSpec twice; it says nothing about dependence on user data. (This behavior doesn't make much sense, either.)


Is this a bug in InstallEventHandler?

As an example, I attempted to install the array event_defs below in the obvious programmatic way.

struct CommandDef {
int evtClass;
int evtType;
EventHandlerUPP handler;
UInt32 targetID;
void * userData;
};
typedef struct CommandDef CommandDef;

static OSStatus Keypress( EventHandlerCallRef inCallRef,
EventRef inEvent, void *inUserData );


const CommandDef event_defs [] = { { 'keyb', kEventRawKeyDown, Keypress, 0, NULL }, // SUCCEED // Bug? { 'keyb', kEventRawKeyDown, Keypress, 0, (void*)1 }, // SUCCEED? // Bug? { 'keyb', kEventRawKeyRepeat, Keypress, 0, NULL }, // FAIL? { 'FAKE', 'FAKE', Keypress, 0, NULL } // FAIL? };

_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden
References: 
 >Behavior of InstallEventHandler differs from Reference (10.3.9) (From: P McIlroy <email@hidden>)
 >Re: Behavior of InstallEventHandler differs from Reference (10.3.9) (From: email@hidden)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.