I’m playing around with AS Studio. I have set up a main window. In this window are two buttons (Run, Cancel). If the run button is clicked then the main window is hidden and a status window appears. The status window contains a progress indicator and a button called Stop.
Right now all I’m doing is running a repeat loop to increment the progress indicator. What I would like to be able to do is click the stop button and have action stopped (like say if I were unstuffing a file and I decided I had the wrong one or something.) However, the button in the Status window cannot be clicked (or have any keyboard actions) until the progress indicator completes its looping. So the question is how do I make the button accessible to keyboard or mouse clicks or is this something that has mainly to do with the fact that I’m just looping and not really doing anything?
Thanks
PreTech
on clicked theObject
(*Add your script here.*)
my theWindow(theObject)
end clicked
on awake from nib theObject
(*Add your script here.*)
set visible of window "Main" to false
set visible of window "Status" to true
my startProg()
end awake from nib
on theWindow(t)
if title of window of t is "Main" then
if name of t is "run" then
load nib "Status"
else if name of t is "cancel" then
quit me
end if
else if title of window of t is "Status" then
-- this indicates that the button "Stop" has been pressed. All action should halt.
hide window "Status"
show window "Main"
end if
end theWindow
on startProg()
if visible of window "Status" is true then
--display dialog "v"
set thisWindow to window "Status"
set indeterminate of progress indicator "prog" of thisWindow to false
tell progress indicator "prog" of thisWindow to start
--display dialog "p"
repeat with i from 1 to 100
tell progress indicator "prog" of thisWindow to increment by 1
delay 0.1
end repeat
tell progress indicator "prog" of thisWindow to stop
end if
end startProg
P.S. How do I stop actions without quiting the app?
Model: dual 1.8 G5
AppleScript: 2.1 (80)
Browser: Safari 412.5
Operating System: Mac OS X (10.4)