[This post is recreated after this forum seems to have crashed and deleted the original thread!?]
I use Shane’s NSOpenSave+MyriadHelpers using makeOpenAt_… But the showOver_calling_ causes me trouble if I need to put up another sheet as a result of the previous one. Example:
The ReadMe file says that it “shows an open or save panel as a sheet over the specified window, calling a handler when the sheet is closed”. But the sheet is not really closed until AFTER the handler sheetDone: has finished, which means I can’t put up a new warning sheet until it is finished!
Example of the sheetDone_:
on sheetDone_(theResult) if theResult is not missing value then set output to readfile_(theResult) else return false --i.e user cancelled end if if output is "" then --<here I want to raise an alert if output is empty, but I can't do that since the previous sheet has not yet been closed!> end if end sheetDone_
Ideally, I would like to close the sheet already before the file is being read (since it might take time), but I don’t see how I can do that. In any case, it is absolutely necessary to close the sheet before I show the alert.
Xcode has a rather difficult-to-digest section called “Presenting a Series of Sheets”, but I can’t make use of it.
Also, there is a notification that an NSWindow delegate can automatically receive, namely by using: windowDidEndSheet_, but it is not overly useful since it does not contain any info about which sheet did end (only which window and name of notif).
So, what do I do?
rdelmar responded to this, but when I clicked the link in the notification mail from the forum, the forum said “Bad request. The link you followed is incorrect or outdated”. But luckily, the mail contained some essential lines, so I recreate what Ric wrote:
You could use the following method, and then put your alert in the “showAlert” method:
if output is “” then
performSelector_withObject_afterDelay_(“showAlert”, missing value, 0.1)
Because the forum deleted the whole thread, I mailed Ric, who then added:
". but that is not the best way. You just need to add: myOpenPanel’s orderOut_(me) as the first line in your sheetDone_ method.
That’s a good method that works!
It does however have the drawback that I need to make the variable myOpenPanel global, since the sheetDone_ does not know the reference to the sheet (unless I can query it in some way).
Since I think the whole issue has a general interest to people, I decided to recreate the thread in this post. Maybe someone has additional comments.
The forum software seems to be unreliable. I hope it doesn’t delete more threads…