What do you do when the main window is closed after an alert as sheet is issued ?
If you rely on the alert’s answer to close the window, then you close the window as the sheet is visible!
It should not be a problem to dismiss a sheet from an ordered-out window. but it is. When the window reappears, the toolbar is not reactivated.
So the solution could be:
on alertWILLBEdismissed_(buttonReturned)
dismissAlert_(myAlert) if buttonReturned as string = “OK” then
makeWhatYouHaveToDo()
closeMainWindow()
end if
end – on return from this selector, NSAlert has no more sheet to dismiss (it should be prepared to face it?)
Tell me if I’m completely mistaken: I want to generalize my alerts, but I prefer to do it with standard windows as sheet, because of the better control.
So I call from any part of the program:
and the “general alert window” is:
on userAlert(aText,anInfo,withFilter)
set my gErrorTextString to aText
set my gErrorInfoString to anInfo
gAlertOKButton's setAction_(withFilter)
gAlertCancelButton's setAction_(withFilter)
tell gAlertWindow to showOver_(gWindow)
end
And I can dismiss my sheet window when I want, from any selector called (the sheet has always the same property):
on myRecovery_(sender)
tell current application's NSApp to endSheet_(gAlertWindow)
-- the sheet is away, I can do what I want, even close the window whose sheet was over.
end