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)



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? If so, this may simply be a mechanism for tweaking the behavior of installed handlers (and may be why it succeeds). But if the new data isn't actually passed in, I would say the install API should return an error.

In the 2nd case, I can understand why the event system might want to key off handler addresses, but at minimum this would be a documentation error. My understanding, as well, was that only a different EventSpec (and not handler) would trigger that result.

Incidentally...it may be safer to stick with the defined type UInt32 and not "int". The headers happen to define it as "unsigned long", and the size *could* be different than that of "int". Suppose it were a different size, and you are getting truncated bits...that would make "different" values appear to the system to be the same value.

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
References: 
 >Behavior of InstallEventHandler differs from Reference (10.3.9) (From: P McIlroy <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.