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)”
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”.
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.
-- 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
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.