Document dirty state during field edit

  • I'm pretty sure I've seen someone ask this before but I just can't
    find it in Google. So I'll ask again.

    I have undo/redo working throughout my program but I seem to remember
    earlier that upon opening a document and immediately after beginning
    to change the state of a text field that the document dirty status
    would be changed, before an actual undo was registered on the undo
    stack. (As a result of -objectDidBeginEditing:?)

    Somehow I've disabled this behavior and for the life of me I can't
    determine what I've done wrong or how to get that behavior back.

    Does anyone have any clues?

    Ashley Clark
  • On Oct 31, 2008, at 1:19 AM, Ashley Clark wrote:

    > I'm pretty sure I've seen someone ask this before but I just can't
    > find it in Google. So I'll ask again.
    >
    > I have undo/redo working throughout my program but I seem to
    > remember earlier that upon opening a document and immediately after
    > beginning to change the state of a text field that the document
    > dirty status would be changed, before an actual undo was registered
    > on the undo stack. (As a result of -objectDidBeginEditing:?)
    >
    > Somehow I've disabled this behavior and for the life of me I can't
    > determine what I've done wrong or how to get that behavior back.
    >
    > Does anyone have any clues?

    After a lot of stepping through the debugger I've seen that in new
    NSDocument based projects that edits happening through a controller
    send an -objectDidBeginEditing: to the NSDocument object via
    [NSValueBinder _startChanging].

    In my project though, for some reason I have yet to uncover,
    NSValueBinder's _startChanging method checks to see if my
    NSWindowController subclass responds to objectDidBeginEditing: when
    that returns NO it stops looking and never checks my document
    subclass. If I implement objectDidBeginEditing and
    objectDidEndEditing: and have them forward those messages on to my
    document the document dirty state is represented correctly as it is in
    a new project.

    So, this suggests that somehow I've mucked up the responder chain
    between my window controller and my document but I don't see anywhere
    where I might have done something like that. To be honest though, I'm
    not sure that I'd know how to without reading up a lot more on the
    responder chain anyway. Before I read up on the responder chain to see
    what I might have done, does anyone know if I'm on the right track here?

    Ashley