Re: Changing cursor holding down the ALT key
Re: Changing cursor holding down the ALT key
- Subject: Re: Changing cursor holding down the ALT key
- From: Andreas Mayer <email@hidden>
- Date: Thu, 4 Sep 2003 02:51:58 +0200
Am Mittwoch, 03.09.03 um 22:43 Uhr schrieb Lorenzo:
I would like now to change the cursor when the ALT key is holding down.
I tried keyDown: but it doesn't notify the ALT is pressed until a
charatecr
is pressed too.
#import <AppKit/AppKit.h>
@interface TestWindow : NSWindow {}
@end
#import "TestWindow.h"
@implementation TestWindow
- (void)sendEvent:(NSEvent *)theEvent
{
if ([theEvent type] == NSFlagsChanged) {
[NSApp sendAction:@selector(myFlagsChanged:) to:nil from:theEvent];
}
[super sendEvent:theEvent];
}
@end
And somewhere in the responder chain:
- (void)myFlagsChanged:(NSEvent *)theEvent
{
NSLog(@"tick");
if ([theEvent modifierFlags] & NSAlternateKeyMask) {
// alt pressed
[[NSCursor IBeamCursor] set];
} else {
// alt not pressed
[[NSCursor arrowCursor] set];
}
}
Thanks for the question. This could come in handy some day. ;-)
bye. Andreas.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.