Doc-based app and 'ask-for-save'-dialog box

Hi,

I’m developing a document-based app. All the things are working well, except only one (or two): I don’t know, how to close a doc-window or quit the app with a dialog box for asking to serve or not.
Saving via the menus “Save as…” or “Save” are working automaticaly by the “data representation” event handler. Is this handler accessable by another handler?
I know how to wright a dialog box, I know there are should/will close/quit handlers. I had tried a lot, but without success.

Can anyone help?

Heiner

Maybe I put my problem more precisely:

  1. I set the handler ‘load data representation’:
on data representation theObject of type ofType
	set theWindow to window 1 of theObject
	set theDataSource to data source of table view "daten" of scroll view "daten" of theWindow
	set dieSchuelerDaten to contents of every data cell of every data row of theDataSource
	set theSortColumn to sort column of theDataSource
	
	set theData to {schuelerdaten:dieSchuelerDaten, sortColumnName:name of theSortColumn, sortColumnOrder:sort order of theSortColumn}
	
	return theData
end data representation

  1. I set the Handler ‘should quit’:
on should quit theObject
	if docIsChanged then
		set theReply to display dialog "Änderungen vor dem Schließen sichern?" buttons {"Nein", "Abbruch", "Sichern"} default button {"Sichern"} with icon 0
		set theAnswer to button returned of theReply
		if theAnswer is "Nein" then --don't save
			return true
		else if theAnswer is "Abbruch" then -- cancel
			return false
		else if theAnswer is "Sichern" then -- save
			tell save panel
				set title to "Sichern"
			end tell
			set windowTitle to title of front window
			set theResult to display save panel with file name windowTitle
			if theResult is 0 then -- cancel
				return false
			else if theResult is 1 then -- save
				beep 2
				
				-- How get I an access to 'on data representation theObject of type ofType' ???		
				
			end if
			return true
			
		end if
	end if
end should quit

Heiner

Only for those, who are such a fool as I:

  1. Forgot all that I’ve written above.

  2. The solution is just an abracadabra:
    a) Set in IB the text field handler(s) to Editing – changed

b) Set in the script

on changed theObject – Handler in the text fields
set modified of document of window 1 to true
end changed

That’s all

Heiner

PS
Greetings to Brad