8

In my cocoa app I am displaying a NSPanel as a modal 'window' of another NSPanel using:

[modalPanel setWorksWhenModal:YES];
[[NSApplication sharedApplication] beginSheet:modalPanel modalForWindow:mainPanel modalDelegate:nil didEndSelector:nil contextInfo:nil];

This works, however the NSTextField's that show up in that modal 'window' are not allowing copy and paste.

From searching I found the following thread on Cocoabuilder which seems like pretty much the same problem, however there was no solution given in that thread either.

http://www.cocoabuilder.com/archive/message/cocoa/2007/11/6/192462

That thread says to make sure you are not stopping copy/paste by using validation, but this is not the case for me as I currently do not have any validation on any of the fields.

Is there something special I have to do to get this to work, or does anyone have any ideas of what I could check/try?

Thanks!

kdbdallas
  • 4,513
  • 10
  • 38
  • 53
  • Related question: [Cocoa Keyboard Shortcuts in Dialog Without an Edit Menu](http://stackoverflow.com/questions/970707/cocoa-keyboard-shortcuts-in-dialog-without-an-edit-menu) – Kristopher Johnson Jun 11 '09 at 06:01

1 Answers1

14

Is the "Edit" menu present in your application?

If you delete the edit menu, you lose the built in copy and paste functionality.

xpda
  • 15,585
  • 8
  • 51
  • 82
diciu
  • 29,133
  • 4
  • 51
  • 68
  • I dont have a edit menu as the program lives in the Status Bar and is displayed from the Status Bar menu or a global shortcut – kdbdallas Feb 25 '09 at 19:19
  • 1
    That was it! I added a menu and hooked up the Edit items, and even though the menu doesn't show, it worked! – kdbdallas Feb 25 '09 at 19:40
  • 1
    could you be more explicit about hooking up the edit items? I added the menu, and I still have right click paste but apple-v beeps at me. – danb May 02 '09 at 03:12
  • if the edit menu items are not visible, in your menu, the shortcuts won't work but you will still be able to copy/paste/etc by right clicking – Radu Simionescu Jun 27 '15 at 10:43
  • 1
    @KristopherJohnson archived version of that link: https://web.archive.org/web/20160414044036/http://www.shipsomecode.com/software/enabling-keyboard-shortcuts-with-nsstatusitems/ – stkent Oct 04 '18 at 23:46