I am looking for a method to wait until a sheet is closed to continue running. With the following code, runFunctionY() will execute before my application receives a sender from the cancel or continue button. Instead I would like to have my application wait until the sheet sheetName is closed before processing runFunctionY().
on runApp_(sender)
openSheet()
runFunctionY()
end runApp_
on openSheet()
current application's NSApp's beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo_(sheetName, mainWindow, me, missing value, missing value)
end openSheet_
on cancelButtonClicked_(sender)
current application's NSApp's endSheet_(sheetName)
sheetName's orderOut_(sheetName)
end cancelButtonClicked_
on continueButtonClicked_(sender)
current application's NSApp's endSheet_(sheetName)
sheetName's orderOut_(sheetName)
runFunctionX()
end continueButtonClicked_
I have tried adding a repeat statement to the code but this appears to stall any input. With the repeat statement in place the application stops receiving input and senders for the Cancel and Continue buttons are never received.
property sheetFinished : false
on openSheet()
current application's NSApp's beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo_(sheetName, mainWindow, me, missing value, missing value)
repeat until sheetFinished
end repeat
end openSheet_
on cancelButtonClicked_(sender)
current application's NSApp's endSheet_(sheetName)
sheetName's orderOut_(sheetName)
set sheetFinished to true
end cancelButtonClicked_
on continueButtonClicked_(sender)
current application's NSApp's endSheet_(sheetName)
sheetName's orderOut_(sheetName)
set sheetFinished to true
runFunctionX()
end continueButtonClicked_