Document with Multiple Windows

  • After searching the documentation and the list archives I'm still
    looking for a solution to a nagging little problem: Having a (Core
    data) document that has multiple windows, all of which should
    represent the documents dirtiness and support saving and undo/redo.

    This document has a master-detail relationship.  The main window lists
    and allows the creation, editing and deleting of the master
    components. Additional windows can be opened for the items in the main
    window and are used to create, edit and delete sub-components.
    (Imagine purchase orders with line items.)

    I'm close: I can make edits in the main window and see them in the sub-
    component windows, and vice versa.  But only the main window shows
    dirtiness and can be used to undo/redo.  The additional windows can
    save the document but if I try an undo then I just get a beep.

    It would be nice if there was a simple example of how to do this.
    Aside from that, does anyone have any suggestions?

    Thanks,
    Mike
  • Hi Mike,

    On 2007-11-27, at 14:18, Mike Rossetti wrote:

    > I'm close: I can make edits in the main window and see them in the
    > sub-component windows, and vice versa.  But only the main window
    > shows dirtiness and can be used to undo/redo.  The additional
    > windows can save the document but if I try an undo then I just get a
    > beep.

    In each window controller for the other windows, implement the
    delegate method -windowWillReturnUndoManager:, and return
    [managedObjectContext undoManager].

    I think the dirty status /should/ propagate correctly. Are you
    creating additional window controllers and adding them to your
    NSPersistentDocument instance?

    Jonathon Mah
    <me...>
  • On Nov 27, 2007, at 4:50 PM, Jonathon Mah (<me...>) wrote:
    > Hi Mike,
    >
    > On 2007-11-27, at 14:18, Mike Rossetti wrote:
    >> I'm close: I can make edits in the main window and see them in the
    >> sub-component windows, and vice versa.  But only the main window
    >> shows dirtiness and can be used to undo/redo.  The additional
    >> windows can save the document but if I try an undo then I just get
    >> a  beep.
    >
    > In each window controller for the other windows, implement the
    > delegate method -windowWillReturnUndoManager:, and return
    > [managedObjectContext undoManager].

    That did the trick for undo/redo!  Thanks!

    > I think the dirty status /should/ propagate correctly. Are you
    > creating additional window controllers and adding them to your
    > NSPersistentDocument instance?

    Yes, using:

    [NSBundle loadNibNamed:@"InvoiceEditWindow" owner:document];

    I also tried a specific:

    [document addWindowController:invoiceEditWC];

    and I further tried setting the 'Document Edited' binding for the
    window to the document's isDocumentEdited accessor,

    all of these with no success.

    Mike
previous month november 2007 next month
MTWTFSS
      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