CPTextField + NibApplication: Without menu items Cmd-V wont call paste: #1434

Closed
Toxe opened this Issue Jan 19, 2012 · 10 comments

Projects

None yet

6 participants

@Toxe

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.

@cappbot

Labels: #needs-patch, #new, AppKit, bug. What's next? This issue needs a volunteer to write and submit code to address it.

@daboe01

this bug most likely is also responsible for the lack of Cmd-N opening a new browser window without a menu (confirmed for Safari and FF).

@aljungberg
Cappuccino member

Actually in Cocoa I'm pretty sure that if you remove the menu entirely of an app, cut and paste no longer works at all.

@boucher
Cappuccino member
@daboe01

just curious, why is is browser-native shortcut new window (cmd-N) also blocked without menu?
this results in the user beeing locked in, certainly not expected behaviour.

@daboe01

thanks ross, adding empty menu + [CPMenu setMenuBarVisible:NO] fixed the cmd-N issue for me. best greetings, daniel

@ahankinson

Has this issue been fixed with #1757?

-#new
milestone=0.9.7

@cappbot

Milestone: 0.9.7. Labels: #needs-patch, AppKit, bug. What's next? This issue needs a volunteer to write and submit code to address it.

@ahankinson

I have just tested this by creating a new NibApplication and deleting the menubar. Cmd-V works to paste into a CPTextField.

+#fixed

@cappbot

Milestone: 0.9.7. Labels: #fixed, AppKit, bug. What's next? This issue is considered successfully resolved.

@cappbot cappbot closed this Feb 22, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment