A Problem with Sheets...

Using Shane’s book as a guide, I have converted 3 modal Open panels to 3 sheets. Everything works, but there is a glitch. Each Open panel’s “done” routine calls the next Open panel routine in order. I have it set up this way because each opened file is handled differently (if they were all handled the same, I’d make multiple selections available). The problem is before the first sheet “retracts” the second sheet is displayed. From the second sheet to the third (and final) sheet everything works as it should. A “phantom” disabled first sheet remains over the window after the third sheet “retracts.” None of its buttons are responsive and it won’t go away.

The code is below:

on openOffensiveStatsFile_(sender)
		tell current application's NSOpenPanel to set thePanel to makeOpenAt_types_files_multiples_prompt_title_(path to desktop, {"txt"}, true, false, "Open OFFENSIVE STATS File", "")
		tell thePanel to showOver_calling_(nflSpreadsWindow, "openOffensiveStatsFileDone:")
	end openOffensiveStatsFile_
	
	
	on openDefensiveStatsFile_(sender)
		tell current application's NSOpenPanel to set thePanel to makeOpenAt_types_files_multiples_prompt_title_(path to desktop, {"txt"}, true, false, "Open DEFENSIVE STATS File", "")
		tell thePanel to showOver_calling_(nflSpreadsWindow, "openDefseniveStatsFileDone:")
	end openDefensiveStatsFile_
	
	
	on openLeagueStatsFile_(sender)
		tell current application's NSOpenPanel to set thePanel to makeOpenAt_types_files_multiples_prompt_title_(path to desktop, {"txt"}, true, false, "Open LEAGUE STATS File", "")
		tell thePanel to showOver_calling_(nflSpreadsWindow, "openLeagueStatsFileDone:")
	end openLeagueStatsFile_
	
	
	on openOffensiveStatsFileDone_(theResult)
		if theResult = missing value then
			-- cancel button
			log "Cancel pressed"
		else
			tell current application to set offStatsRaw to paragraphs of (read file (theResult as text))
			getOffensiveStats(offStatsRaw)
			openDefensiveStatsFile_(me)
		end if
	end openOffensiveStatsFileDone_
	
	
	on openDefseniveStatsFileDone_(theResult)
		if theResult = missing value then
			-- cancel button
			log "Cancel pressed"
		else
			tell current application to set defStatsRaw to paragraphs of (read file (theResult as text))
			getDefensiveStats(defStatsRaw)
			openLeagueStatsFile_(me)
		end if
	end openDefseniveStatsFileDone_
	
	
	on openLeagueStatsFileDone_(theResult)
		if theResult = missing value then
			-- cancel button
			log "Cancel pressed"
		else
			tell current application to set leagueStatsRaw to paragraphs of (read file (theResult as text))
			getLeagueStats(leagueStatsRaw)
		end if
	end openLeagueStatsFileDone_

Is there a problem with my code or is this a glitch in either ASOC or the Myriad Helpers? The getOffensiveStats(), getDefensiveStats() and getLeagueStats() are handlers that have been working fine. I originally wrote the open handlers using modal dialogs.

btw, Shane, I’m not trying to imply that your Myriad Helpers are at fault. I appreciate the time and effort you have put into these to make our lives easier.

Thanks in advance,
Brad Bumgarner

The problem is that the panels aren’t getting a chance to close properly because your callback handler opens another before it ends and lets screen updating occur. You need to let things update between sheets.

So where you call the second sheet from the first sheet’s callback handler, change this:

 openDefensiveStatsFile_(me)

to something like:

my performSelector_withObject_afterDelay_("openDefensiveStatsFile:", me, 0)

And so on.

Thanks Shane,

I had a feeling it was a timing issue…I just wasn’t sure and I didn’t really know where to look.

Thanks,
Brad Bumgarner