Re: Capturing all the events in Full Screen Mode... Uhhh...
Re: Capturing all the events in Full Screen Mode... Uhhh...
- Subject: Re: Capturing all the events in Full Screen Mode... Uhhh...
- From: Troy Dawson <email@hidden>
- Date: Tue, 30 Oct 2001 09:49:13 -0800
on 10/30/01 4:18 AM, Alexandre Aybes at email@hidden wrote:
>
Hi there,
>
When I am in full screen mode to get the events I use
>
[NSApp currentEvent]; and then dispatch the events by hand to my
>
listeners...
you're going to need to override NSApplication's -sendEvent method, see
below.
[the following code is taken from the 'VBL' sample of an upcoming WWDR
OpenGL sample code distribution (due for posting hopefully RSN)]:
#import <Cocoa/Cocoa.h>
/* -----
Notes
-----
1) In IB the MainMenu.nib the File's Owner custom class is set to App
2) In PB the Application settings Principal class is set to App
*/
@interface App : NSApplication
{
NSTimer* update_timer;
}
@end
@implementation App
- (id) init
{
self = [super init];
[self setDelegate: self];
return self;
}
- (void) dealloc
{
[update_timer invalidate];
[update_timer release];
[super dealloc];
}
- (void) sendEvent: (NSEvent*) theEvent
{
NSEventType event_type = [theEvent type];
if (event_type == NSKeyDown || event_type == NSKeyUp)
;
[super sendEvent: theEvent];
}
- (void) applicationWillFinishLaunching: (NSNotification*) notification
{
}
- (void) update : (id) object
{
}
- (void) applicationDidFinishLaunching: (NSNotification*) notification
{
update_timer = [[NSTimer scheduledTimerWithTimeInterval: 0.001 target:
self selector:@selector(update:) userInfo:self repeats:true] retain];
}
int main(int argc, const char *argv[])
{
return NSApplicationMain(argc, argv);
};
@end