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 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]