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 protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]