NSTableView and Copy/Pasting/Deleting

  • How does one implement a proper Edit menu when
    NSTableViews are involved? I've got a typical
    master-detail interface with two tables and some text
    fields, all implemented using the bindings system.

    I would like the Copy/Paste/Delete commands of the
    Edit menu to work on both the text fields (they
    already do by default of course) and the tables. Of
    course, when one of the tables is highlighted, but
    there's no selection in the table, the Copy/Delete
    commands should be greyed out.

    This seemed like a mundane Cocoa thing that should be
    easy to achieve but I'm having a hard time figuring it
    out. I took a look at the iSpend example over at the
    and strangely, when you highlight the table the
    Copy/Paste/Delete commands are *not* greyed out even
    if the table is empty! Is this harder to achieve than
    I would think it should be?

    Where can I find how to implement this properly and

    Do You Yahoo!?
    Tired of spam?  Yahoo! Mail has the best spam protection around
  • On Jun 18, 2005, at 4:45 PM, Kris Gybels wrote:

    > Where can I find how to implement this properly and
    > cleanly?

    Your controller should implement -validateMenuItem: (see http://
    ObjC_classic/Protocols/NSMenuValidation.html).  The example on that
    page is misleading -- you should check the menu item's selector, not
    the title.  If the selector is copy:, then check to see if the
    current selection is copyable.

previous month june 2005 next month
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      
Go to today