Hi,
I have a document-based app but I only want to use the documents to save the current values of certian elements in my window instead of creating entire documents. I know I can use User Defaults to save preferences, but I want to save the results in a document.
Right now, I have a simple window with 4 text fields, just to see if it can be done. I want to save the contents of the text fields into a list in a document, and then have them be refilled when the document is opened again. I have:
on data representation theObject of type ofType
set textFields to {}
repeat with i from 1 to number of text fields of window 1
set textFields to textFields & (contents of text field i of window 1)
end repeat
return textFields
end data representation
on load data representation theObject of type ofType with data withData
repeat with i from 1 to number of text fields of window 1
set contents of text field i of window 1 to (item i of withData)
end repeat
return true
end load data representation
The problem with this code is that it creates a document, and when the user clicks the ‘new’ button, more and more windows pop up. I want there to only be one window whose values change.
Also, if I can’t do that, can I change the title of the document window? I’ve tried ‘set title of window 1’ and ‘set title of document 1’.
If that wasn’t enough, I’d also like to know if there’s a way to change the icon that my documents use. I know how to change the extension and creator code, but where do I add an icon? Does that have something to do with the class of the file?
Thanks,
EN