Progress Bar in Panel: Can't get window

I have a main window titled “wMain” and I am trying to open a progress bar as a sheet attached to this main window. The code that opens the progress bar is:

    display panel window "progressPanel" attached to window "wMain"

However when I get to this line my application complains that it “Can’t get window “wMain”. (-1728)”

I robbed this code from an example posted in this forum and the example compiles and runs correctly.

Before I moved the progress bar to this new window I had it in my “wMain” window and everything worked correctly, so I know that my script can generally access the “wMain” window. But this window attached to window is new territory for me.

Furthermore, if I replace the above line with:
show window “progressPanel”

Then my application proceeds, however the separate window for the progress bar always displays instead of coming up just when I call “show window”.

Can anyone help?

I battled some more today this progress-bar-in-a-sheet thing looking at Apple’s examples as well as the example I mentioned in my previous post.

I have created a small example that removes all of my application’s smarts and still doesn’t attach the progress bar to the window like the other examples do.

http://www.automaticduck.com/screenshots/attachedProgressBar.zip

Can anyone see what I’m doing wrong?

The script is:


-- A button was clicked
on clicked theObject
    
    if the name of theObject is "cancel" then
        quit
    else if the name of theObject is "userSetSourceChoose" then
        
        display dialog "this doesn't actually do anything"
        
    else if the name of theObject is "userSetDestinationChoose" then
        
        display dialog "this doesn't actually do anything"
        
    else if the name of theObject is "Copy" then
        
        display panel "ProgressBar" attached to window "Main"
        
        tell window "ProgressBar"
            set maximum value of progress indicator "progressIndicator" to 100
            set indeterminate of progress indicator "progressIndicator" to false
            repeat with i from 1 to 100
                set contents of progress indicator "progressIndicator" to i
                set contents of text field "ProgressText1" to "some progress: " & i & " of 100"
                
                -- stuff
                
                delay 0.05
            end repeat
        end tell
        
        close panel window "ProgressBar"
        
    end if
end clicked


Wes Plate
Automatic Duck, Inc.
http://www.automaticduck.com

I’m not sure exactly what your troubles are but you could try using the BWToolkit Framework. It comes with a sheet controller so you can connect the button to the sheet right in interface builder without having to write the code to do it.

Thank you. I’m going to try to get around my problem by getting my code into an example that works with the sheet coming down.

And thank you for the plug-in suggestion, I’ll look into it. One question about it, the Release Notes say

If you need to reference BWToolkit objects in your classes, you can import the main header like so:
#import <BWToolkitFramework/BWToolkitFramework.h>

How do I do that? I’m very new to AppleScript Studio and my previous programming experience is only AppleScript (and that mostly copy and paste).

I got a reply on Apple’s AppleScript Studio list that fixed my problem.