NSevent handling in panther
NSevent handling in panther
- Subject: NSevent handling in panther
- From: Dingcai Cao <email@hidden>
- Date: Sun, 27 Feb 2005 11:25:35 -0600
Dear all,
Currently I encountered a very strange situation. I developed some objective-C codes for gamepad event handling long time ago in Jaguar's project builder, which worked very well. Now I tried to run the same codes in Panther's Xcode. There was no problem to recompile the program, but I could not run it. The warning message looked like this:
2005-02-26 22:12:04.724 CFF[934] *** Assertion failure in -[NSEvent keyCode], AppKit.subproj/NSEvent.m:871
2005-02-26 22:12:04.729 CFF[934] Invalid message sent to event "NSEvent: type=SysDefined loc=(682,505) time=16551.7 flags=0x100 win=0 winNum=0 ctxt=0xc2a7 subtype=7 data1=1 data2=0"
Note CFF is the name of my project. I understand the message indicates run-time errors. But I have no idea why the same code was OK in Jaguar but not in Panther. Can anyone tell me what is going on? I highly appreciate your help. Here are my codes.
Dingcai Cao
/* GamePad */
#import <Cocoa/Cocoa.h>
@interface GamePad : NSObject
{
NSDate *distantPast ;
NSEvent *event;
NSEventType eventType;
unsigned int eventFlags;
unsigned int eventKey;
}
-(void)setEvent;
-(int)handleEvent;
@end
/* GamePad.m */
#import "GamePad.h"
@implementation GamePad
-(void) setEvent {
distantPast= [[NSDate distantPast] retain];
event = [NSApp
nextEventMatchingMask: NSAnyEventMask
untilDate: distantPast
inMode: NSDefaultRunLoopMode
dequeue: YES ];
}
-(int) handleEvent
{
if (event)
{
eventType = [event type];
eventFlags = [event modifierFlags];
/// eventKey = [event keyCode];
eventKey = [event performSelector:@selector(keyCode)];
switch (eventType) {
case NSKeyDown:
if ((eventKey + eventFlags) == QUIT) exit(1);
printf("%0x\n", eventKey+ eventFlags);
return eventKey+ eventFlags;
break;
case QUIT:
exit(1);
break;
}
}
return 0;
}
@end
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden