becomeFirstResponder and keyDown
becomeFirstResponder and keyDown
- Subject: becomeFirstResponder and keyDown
- From: "gMail.com" <email@hidden>
- Date: Wed, 21 Oct 2009 18:17:33 +0200
- Thread-topic: becomeFirstResponder and keyDown
Hi,
I would like to detect whether the 'e' key is pressed every time I click on
an NSView. If the view is already the firstResponder, I can quite memorize
that key pressed when keyDown and reuse it when mouseDown. Then I erase it
when keyUp.
But if the user presses the 'e' key when the firstResponder is on another
view, then he clicks on my view, I cannot detect that the 'e' is still
pressed. I have been trying to detect the key already pressed subclassing
becomeFirstResponder but I get nothing. Any idea?
- (BOOL)becomeFirstResponder
{
unsigned int eventMask = NSKeyDownMask;
NSEvent *theEvent = [[self window]
nextEventMatchingMask:eventMask untilDate:nil
inMode:NSEventTrackingRunLoopMode dequeue:YES];
NSEventType eventType = [theEvent type];
if(eventType == NSKeyDown){
mCharCurrentlyPressed = [[theEvent charactersIgnoringModifiers]
characterAtIndex:0];
NSLog(@"becomeFirstResponder %c", mCharCurrentlyPressed );
}
return YES;
}
Best Regards
--
LL
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden