Using custom sheet instead of a dialog window

All,
I want to replace a standard dialog window in my app by a custom sheet (AppleScriptObjC Explored Book).
Everything is setup correctly. The custom sheet is used to display warnings and provides Continue/Exit buttons to the user. If user chooses “Continue” then the App can resume execution. My app has 2 tabs. On Tab 1, user inputs data and submits it. If validation is fine, then after hitting the submit button on Tab 1, I switch to Tab 2 to display results.

Here is my code so far:


set checkNum to aNum's stringValue() as string
if checkNum is equal to "" then
     tell aDialogWindow to showOver_(aWindow) 
    # Logic that will suspend execution and resume after user chooses Continue button in Custom Sheet
end if 

#.... Some More Code
myTabView's selectTabViewItem_(tab2)


In the code above I have a field called Phone Number. If user doesn’t provide a value, I want to display the sheet with a generic warning. if user taps “Continue” button in the sheet , the execution should resume. But currently, after the sheet opens, my App progresses to Tab2.

is it possible to suspend execution ?

You need to put your code that switches to tab2 in a handler that’s called when the user clicks the continue button in the sheet. Showing the sheet doesn’t stop the code after it in the same method from running. You want it to look something like this:

on textEntered_(sender) -- IBAction for the text field
		if sender's stringValue() as string is equal to "" then
			tell aDialogWindow to showOver_(aWindow)
		end if
		log "got here" -- this gets logged right after the sheet shows. Don't put code here that's conditional on a response
	end textEntered_
	
	on continueClicked_(sender) -- IBAction for the continue button on the sheet
		log "switching to tab2"
		current application's NSApp's endSheet_(aDialogWindow)
	end continueClicked_

Ric