Progress Panel as sheet

Hi,
I would like to know how to close a sheet Window after finishing a process, for example I am uploading a photo and a sheet Window is displayed saying “Wait for the photo to load” so when you finish loading the photo this sheet Window can close without the need to hit the “OK” button or any other.

I use this:

set alert to current application's NSAlert's alloc's init()
        tell alert
            its setMessageText:""
            its setInformativeText: ""
            its setAlertStyle:2
            its setShowsSuppressionButton:false
            its beginSheetModalForWindow:theWindow modalDelegate:me didEndSelector:(missing value) contextInfo:(missing value)
end tell

You call -endSheet:. It the window showing the sheet is mainWindow, then:

mainWindow's endSheet:(mainWindow's attachedSheet())

Thanks @Shane Stanley, working like a charm!
one more question:
Is there any way to insert a progress bar or an indeterminate progress indicator, if so how would it be done?

Either use a window instead of an alert as the sheet, or add it as the alert’s accessoryView.

I never used alert’s accessoryView but I will try, thanks!:slight_smile:

If not asking too much could you give me an example?

If the view you want to appear in the alert is called someView, it’s:

alert's setAccessoryView:someView

Thanks for the answer,
Honestly I could not, alias I did not quite understand how would add a Progress Indicator there a Panel Sheet.

Is there any way to launch the App with a certain window and after a few seconds this window will close automatically and open a second window? if so how could i do?
I know I can use

orderOut_ (me)

to hide and

makeKeyAndOrderFront_ (me)

to show another window.
but how can i close the first automatically after a few seconds?

You can use an NSTimer.

thanks for the help Shane.

Is there any way to display a sheet window without the app icon?

You can display any window as a sheet, so it’s just a matter of building your own window.

@shane,
Would it be too much to ask you for an example?

It’s not code – you create a new window in Xcode. Add whatever buttons you want, and connect them to handlers that close the sheet. Then have your main window call beginSheet:completionHandler:, passing an outlet to the sheet window and missing value.

@shane,
I try this but not working:

script AppDelegate
	property parent : class "NSObject"
	
	-- IBOutlets
	property theWindow : missing value
    property Window : missing value ---outlet for the new window
	
	on applicationWillFinishLaunching_(aNotification)
		-- Insert code here to initialize your application before any files are opened 
	end applicationWillFinishLaunching_
	
	on applicationShouldTerminate_(sender)
		-- Insert code here to do any housekeeping before your application quits 
		return current application's NSTerminateNow
	end applicationShouldTerminate_
    
    on openSheet:sender
        tell class "NSApplication" of current application
            its sharedApplication's beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo_(Window, theWindow, me, missing value, missing value)
          end tell
        end openSheet:
    end script[/AppleScript]
button "Open" is create in the mainWindow aka theWindow.

Perhaps you should try what I posted.

on openSheet:sender
        theWindow's beginSheet:Window completionHandler:(missing value)
  end openSheet:

I’m sorry, I’m slow to understand but I get there.
thanks, again!

Could you tell me how I do the same using:

runModal ()

I tried:

stopModal ()

but to no avail here.

Try:

current application's NSApp's stopModal()