Failed to capture Key Equivalent on Mac 10.4 but Succeeded on Mac 10.5
Failed to capture Key Equivalent on Mac 10.4 but Succeeded on Mac 10.5
- Subject: Failed to capture Key Equivalent on Mac 10.4 but Succeeded on Mac 10.5
- From: Kan Cheng <email@hidden>
- Date: Mon, 25 Feb 2008 18:12:45 -0800
- Acceptlanguage: en-US
- Thread-topic: Failed to capture Key Equivalent on Mac 10.4 but Succeeded on Mac 10.5
Dear all,
I'm writing a demo which is a carbon application hosting a WebView but without menu. Then I found that the pasting/copying/cutting functionality does not work on WebView when Command+V keys down event is raised.
So that I implemented the performKeyEquivalent: method to capture the Key Equivalents Command+V/C/X as below. And it works fine on Mac 10.5 now, but fail on Mac 10.4 -- performKeyEquivalent: will never be called on Mac 10.4 when Command+V/C/X keys dow. Can anyone help me to figure out why? Thanks!
@interface WebView (WebViewExt)
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent;
@end
@implementation WebView (WebViewExt)
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
{
if ( [theEvent modifierFlags] & NSCommandKeyMask)
{
NSString *chars = [theEvent charactersIgnoringModifiers];
if ([chars isEqualToString:@"x"])
{
[self cut:self];
return YES;
}
if ([chars isEqualToString:@"c"])
{
[self copy:self];
return YES;
}
if ([chars isEqualToString:@"v"])
{
[self paste:self];
return YES;
}
}
return [super performKeyEquivalent:theEvent];
}
@end
Best Regards
Kan Cheng
_______________________________________________
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