Cocoa Keyboard Shortcuts in Dialog without an Edit Menu?

Improving on that CocoaRocket solution: The following saves having to subclass NSTextField and remembering to use the subclass throughout your application; it will also enable copy, paste and friends for other responders that handle them, eg. NSTextView. Put this in a subclass of NSApplication and alter the principal class in your Info. Plist accordingly.

- (void) sendEvent:(NSEvent *)event { if (event type == NSKeyDown) { if ((event modifierFlags & NSDeviceIndependentModifierFlagsMask) == NSCommandKeyMask) { if (event charactersIgnoringModifiers isEqualToString:@"x") { if (self sendAction:@selector(cut:) to:nil from:self) return; } else if (event charactersIgnoringModifiers isEqualToString:@"c") { if (self sendAction:@selector(copy:) to:nil from:self) return; } else if (event charactersIgnoringModifiers isEqualToString:@"v") { if (self sendAction:@selector(paste:) to:nil from:self) return; } else if (event charactersIgnoringModifiers isEqualToString:@"z") { if (self sendAction:@selector(undo:) to:nil from:self) return; } else if (event charactersIgnoringModifiers isEqualToString:@"a") { if (self sendAction:@selector(selectAll:) to:nil from:self) return; } } else if ((event modifierFlags & NSDeviceIndependentModifierFlagsMask) == (NSCommandKeyMask | NSShiftKeyMask)) { if (event charactersIgnoringModifiers isEqualToString:@"Z") { if (self sendAction:@selector(redo:) to:nil from:self) return; } } } super sendEvent:event; }.

Perfect solution! Another downside of the original was that you'd have to 'redefine' subclasses of NSTextField too, like NSSearchField. – Nikita Rybak Feb 4 at 16:21 I've amended this to include redo.

– Adrian Aug 31 at 22:41.

I had the same problem as you, and I think I've managed to find a simpler solution. You just need to leave the original main menu in MainMenu. Xib - it won't be displayed, but all the actions will be handled properly.

The trick is that it needs to be the original one, if you just drag a new NSMenu from the library, the app won't recognize it as Main Menu and I have no idea how to mark it as such (if you uncheck LSUIElement, you'll see that it won't show up at the top if it's not the original one). If you've already deleted it, you can create a new sample app and drag a menu from its NIB, that works too.

What worked for me was using The View Solution presented in Copy and Paste Keyboard Shortcuts at CocoaRocket. Basically, this means subclassing NSTextField and overriding performKeyEquivalent:. Since CocoaRocket is dead, here's the Internet Archive link: web.archive.org/web/20100126000339/http:....

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions