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?
};