Mark a NSTextView as edited

Hello,

In a non document-based application, how do you set (and reset) a “edited” flag? Making the app the delegate and intercept the textDidBeginEditing_ notification is fine, but how do you reset the non-edited state after saving the file?

Thanks!

Just reset it inside your save method. I have a property called isEdited in my app which is set to false in its declaration, and then is set to true inside the textDidChange method. Then, in my writeToFile method, after saving, I set isEdited to false again. To make your app look like a standard Apple app, you should also bind the window’s Document Edited parameter to the isEdited property — that will cause a black dot to appear inside the red close button on your window showing that it has unsaved changes.

Ric

Hello Ric – I feel really stupid:

Your suggestion was the exact way I did this initially, setting my “gDirty” property in the textDidChange method. But for some reason, this method was never called. I made a mistake somewhere deep into the bindings, I suppose, the same as some programmers – including Objective-C programmers :

So I tried with the shouldBeginEditing_ call, which worked - but only once for the whole run. Not good.

And suddenly, it works with textDidChange_… and I don’t know what I have changed. It works, but I feel insecure. Know the feeling?

Regards