cappuccino/cappuccino — Issue #1434: CPTextField + NibApplication: Without menu items Cmd-V wont call paste:
Author: Toxe
Created: 2012-01-19 13:55:43+00:00
State: open

*I am not sure if this really qualifies as a bug, but I wanted to report it anyways, because I can imagine other people running into this problem as well.*

If you generate a new application using the `capp gen` NibApplication template and afterwards in InterfaceBuilder **remove the menu bar from your NIB file**, paste and cut wont work any longer with CPTextField. Cmd-V and Cmd-X should invoke the `paste:` and `cut:` messages of CPTextField but this only works as long as the menu bar with its Paste and Cut menu items exists. And without invoking the `paste:` and `cut:` messages CPTextField wont send its textDidBeginEditing, textDidChange, ... notifications, which is a big problem if you are using bindings.

A simple workaround would be to manually add the key bindings in `applicationDidFinishLaunching:`

- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
// This is called when the application is done loading.
[CPKeyBinding cacheKeyBinding:[[CPKeyBinding alloc] initWithPhysicalKeyString:@"@v" selectors:[CPArray arrayWithObject:@"paste:"]]];
[CPKeyBinding cacheKeyBinding:[[CPKeyBinding alloc] initWithPhysicalKeyString:@"@x" selectors:[CPArray arrayWithObject:@"cut:"]]];
}

After this paste and cut works as it should.