MyriadHelpers

I’m using MyriadHelpers NSOpenSave & NSAlert. For my application I have an open sheet attached to my main window and once a folder is selected I’m doing other automated things. During some of these things are tests and if something is not right I want to drop as a sheet an NSAlert also attached to the main window. This doesn’t work because I’m calling it inside the openSheetDone handler and it wants to drop the new sheet before the open sheet is closed…? is there anyway around this and still be able to use sheets?


    on showOpenPanel_(sender)
		tell current application's NSOpenPanel to set thePanel to makeOpenAt_types_files_multiples_prompt_title_("", {"folder"}, false, false, "Choose a folder:", "My Open Title")
		tell thePanel to showOver_calling_(mainWindow, {"openSheetDone:", me})
	end showOpenPanel_
	
	on openSheetDone_(theResult) -- called when panel closed
		if theResult = missing value then
			-- cancel button
			log "Cancel pressed"
            else
			log theResult 
            doThis()
		end if
	end openSheetDone_
    
    on doThis()
        showAlertAsSheet(mainWindow, "Missing Information Alert", "Missing Description.")
    end doThis
    
	on showAlertAsSheet(windowName, titleCaption, subTitleCaption)
		tell current application's NSAlert to set theAlert to makeAlert_buttons_text_(titleCaption, {"Cancel"}, subTitleCaption)
		theAlert's showOver_calling_(windowName, {"alertDone:", me})
	end showAlertAsSheet
    
    on alertDone_(theResult)
		return
	end alertDone_

You probably need to call the handler that shows the second sheet using performSelector:withObject:afterDelay:, to allow the closing event to finish before the new sheet is shown.

Yes, that did it… Thanks!


on openSheetDone_(theResult) -- called when panel closed
	if theResult = missing value then
		-- cancel button
		log "Cancel pressed"
            else
		log theResult 
                performSelector_withObject_afterDelay_("doThis", missing value, .5)
	    end if
end openSheetDone_