Hallo,
I’m developing an app in AS studio and have to handle table view datas.
To save and open datas the procedures ‘on data representation’ and ‘on load data representation’ are working well. The saved files have only an empty sheet as an
icon; is there a possibility to show that icon with my own added icon?
Before closing the window I want to ask the user for saving or not. The ‘should close’ handler doesn’t work (not even a beep). The ‘will close’ handler has reactions, but it is not possible to prevent closing for ‘cancel’. How is that problem to solve?
Before quitting the app, I want also to ask the user for saving or not. I tried it with a ‘should quit’ handler, but without success. I show you my attempt below.
Sorry for my bad English and thank you for your help.
Heiner
on should quit theObject
if hasChanged then
set theWindow to front window
set theReply to display dialog "Änderungen vor dem Schließen sichern?"
buttons {"Nicht sichern", "Abbrechen", "Sichern"} default button "Sichern" with icon 0 -- attached to window theWindow (it does not work)
set theAnswer to button returned of theReply
if theAnswer is "Nicht sichern" then -- not saving
return true
else if theAnswer is "Abbrechen" then -- cancel
return false
else if theAnswer is "Sichern" then -- save
tell save panel
set title to "Noten Oberstufe: Sichern"
set prompt to "Sichern"
-- set treat packages as directories to false
end tell
set theResult to display save panel with file name "OhneNamen"
if theResult is 1 then -- Save
-- the 4 following lines are the same as in the 'on data representation'-handler:
set schuelerdaten to data source of table view "daten" of scroll view "daten" of theWindow
set dieDaten to contents of every data cell of every data row of schuelerdaten
set theSortColumn to sort column of schuelerdaten
set theData to {daten:dieDaten, sortColumnName:name of theSortColumn, sortColumnOrder:sort order of theSortColumn}
-- I don't know, if these is necessary:
set longFileName to path name of save panel
set fileName to POSIX path of longFileName
-- nothing to say about that:
save theData in file fileName
return true
else if theResult is 0 then -- Cancel
return false
end if
end if
else
return true
end if
end should quit
Model: eMac
Browser: Safari 312
Operating System: Mac OS X (10.3.9)